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 Statement

Author  Topic 

nvakeel
Yak Posting Veteran

52 Posts

Posted - 2008-02-11 : 13:13:02
DECLARE @TABLE1 tABLE ( NUM iNT , VAL vARCHAR(10))
declare @vir varchar(10)

iNSERT INTO @TABLE1 vALUES (1,'JJ')

iNSERT INTO @TABLE1 vALUES (2,'J')

iNSERT INTO @TABLE1 vALUES (3,'JJJ')

--sELECT * FROM @TABLE1

update @table1
Set Num = 3,
Val = (select @vir = 'jj')


can you tell me is this approach correct ?

hey001us
Posting Yak Master

185 Posts

Posted - 2008-02-11 : 13:53:45
should be like this?
update @table1
set val = 'jj'
where num = 3


hey
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2008-02-11 : 13:54:48
Or
update @table1
set val = @vir
where num = 3

hey
Go to Top of Page
   

- Advertisement -