Click here to Skip to main content
15,037,662 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i have a table name "table1" and column name "amount" , "2001", "2002","2003","2004"
there are 15000 records in the table.
i have a float value in column "amount"
i have to update 2001 as ( 2001 = amount *10/100)
2002 as ( 2002 = amount *15/100)
2003 as ( 2001 = amount *20/100)
2004 as ( 2001 = amount *22/100)



what should be the code to update all these columns in a single transaction. when i use the following code, i can update only one column not 4 columns

update "table1"
set 2001 as ( 2001 = amount *10/100)

plz help.
Posted

Try:
SQL
UPDATE myTable SET [2001]=amount *10/100, [2002]=amount*15/100
And so forth.
   
how to apply conditional update in database
means
if year is less than 2009 update 20% in pay
else if greater than 2009 update 15% in pay

how to apply that in sql server query i want to develop a logic like this way
if year is less than 2009
a = 20%
else if year is greater than 2009
a = 15%
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900