Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 UPDATE two columns

Author  Topic 

sfjtraps
Yak Posting Veteran

65 Posts

Posted - 2009-09-16 : 15:51:14
I'm using the code below to UPDATE one column in a table. What is the syntax for updating another column in the same code? For instance, if I wanted to SET column1=0 and column2=15.


use [database]
go
update [table]
set column1=0

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-16 : 16:05:03
dont forget a WHERE clause to limit which rows you are updating. No where clause means you update every row in the table.

update [table] set
[column1]=0
,[column2]=2
where ...


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -