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 2000 Forums
 Transact-SQL (2000)
 update

Author  Topic 

mdhingra01
Posting Yak Master

179 Posts

Posted - 2004-03-24 : 15:25:19
is there away to update mulitple columns in one statment either using update or case?

Thanks

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-03-24 : 15:28:56
UPDATE MyTable
SET Col1 = 'NewVal',
Col2 = 'NewVal'

Duane.
Go to Top of Page

mdhingra01
Posting Yak Master

179 Posts

Posted - 2004-03-24 : 15:31:32
What if NewVal1 and NewVal2 are coming from another table is this still possible?

thanks Duane!
Go to Top of Page

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2004-03-24 : 15:49:09
More than one table can be involved in an update if you updating a view.

Justin

"Hit me with a shovel 'cause I can't believe I dug you."
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-03-24 : 15:56:02
[code]
UPDATE a
SET Col1 = b.Col1
, Col2 = b.Col2
FROM Table1 a
INNER JOIN Table2 b
ON a.[id] = b.[id]
[/code]


Brett

8-)
Go to Top of Page

mdhingra01
Posting Yak Master

179 Posts

Posted - 2004-03-24 : 16:02:20
Thanks guys for the help.

I appreciate it.
;c)
Go to Top of Page
   

- Advertisement -