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.
| Author |
Topic |
|
sqldba2k6
Posting Yak Master
176 Posts |
Posted - 2007-02-21 : 16:07:51
|
| Please help..I am writing a update query which has to update the @prod2 table column prod1 with the values of @Upprod table column prod2.Please correct the query if anything needs to be corrected in the below query.there are nearly 1500 records to be updated below is sample data..declare @Prod2 table(Csid bigint,Prod1 numeric(5))insert into @Prod2select 4103, 1946 union allselect 4101, 1956 union allselect 4102, 1904select * from @prod2 order by csiddeclare @Upprod table(Csid int,Prod2 numeric(5))insert into @Upprodselect 4102, 1956 union allselect 4103, 1936 union allselect 4101, 1964select * from @Upprod order by csidupdate @prod2 set prod1=Prod2 from @prod2 A,@Upprod BWhere A.csid=B.csidselect * from @prod2 order by csid |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-02-21 : 16:25:38
|
| Your userid indicates you are a DBA, so you should start using join syntax:update Aset prod1 = b.Prod2 from @prod2 Ainner join @Upprod Bon A.csid = B.csidTara Kizer |
 |
|
|
|
|
|