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
 General SQL Server Forums
 New to SQL Server Programming
 how to get multiple column and set into other tab

Author  Topic 

nitin05.sharma
Starting Member

20 Posts

Posted - 2011-07-04 : 10:02:18
hi

i am workin on sql server 2005

i want to get multiple column of a row from a table and set into other table on the basis of corresponding ID

i used this

update YM_StoreInfo
(select old.Address1 old_Add1,old.Address2 old_Add2,new.Address1 new_add1,new.Address2 new_add2
from YM_StoreInfo old LEFT JOIN
YM_UpdateStoreInfo new
ON old.ID = new.StoreInfoID where old.ID=1)
SET old_Add1=new_add1,
old_Add2=new_add2



but this give an error

just lke

incorrect syntax near ')'

just lke incorrect syntax near '('

please help me

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-04 : 10:10:27
You're not in Kansas (MS Access) any longer!
UPDATE		si
SET si.Address1 = usi.Address1,
si.Address2 = usi.Address2
FROM YM_StoreInfo AS si
LEFT JOIN YM_UpdateStoreInfo AS usi ON usi.StoreInfoID = si.ID
WHERE si.ID = 1



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

nitin05.sharma
Starting Member

20 Posts

Posted - 2011-07-04 : 10:15:03
hi
thanks swepeso
i tried this
but its not working
it gives "The multi-part identifier "old.Address1" could not be bound." such kind of error
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-04 : 10:28:13
No, it's not.
Copy and paste my suggestion by the letter and try again.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2011-07-04 : 11:42:15
Or post the new code you tried.

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

nitin05.sharma
Starting Member

20 Posts

Posted - 2011-07-05 : 02:25:23
HI
thanks swepeso
now its working fine
thanks alot
Go to Top of Page
   

- Advertisement -