Is there a syntax error with this SQL server query? Can I not use "target.@1"? -


hard coded, works:

var insertcommand1 = ("merge leaderboard (holdlock) target using (select * scores weeknumber = 7) source on (target.id = source.id) when matched update set target.id  = source.id, target.week7 = source.weeklyscore when not matched insert (id, week7) values (source.id, source.weeklyscore);");  db.execute(insertcommand1); 

this not work:

var insertcommand1 = ("merge leaderboard (holdlock) target using (select * scores weeknumber = @0) source on (target.id = source.id) when matched update set target.id  = source.id, target.@1 = source.weeklyscore when not matched insert (id, @2) values (source.id, source.weeklyscore);");  db.execute(insertcommand1, weeknum, weekstring, weekstring); 

the error says there's syntax error near @1. be? i've debugged make sure value weeknum , weekstring correct.

working in sql server on vs 2015.

schema 2 tables-

leaderboard(id, week1, week2, week3, week4, week5,                  week6, week7, week8, week9, week10)  id primary key  scores(id, weeknumber, weeklyscore)  id , weeknumber primary key 

you trying set fieldname using parameter, , @parameters values.

 , target.@1 = source.weeklyscore  

should

 , target.something = @1 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -