lundi 21 décembre 2015

Incorrect syntax near 'month' with dynamic number

while running the below query, I get error as

Incorrect syntax near 'month'.

update p_leave_allocation_14122015 
  set 'month' + @actualMonth  = @actualleavedays
    where year = @actualYear  and emp_card_no =  @emp_card_no 

the table p_leave_allocation_14122015 has columns like month1, month2, month3,.....

in my update query what I want is month will be hardcoded and the no of month will be dynamic based on some conditions which I have written.

But when I tried with the above query I got the mentioned error.

I am using SQL server 2005

Kindly suggest

Aucun commentaire:

Enregistrer un commentaire