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 Update

Author  Topic 

Jasonyapkk
Starting Member

3 Posts

Posted - 2012-03-16 : 03:56:37
Hi All, very goodday to all of you.

I need some advice and example on how to update a condition as below:
File1 :IIM
File2 :IIMX

Need to:
1) SET IIMX.IXSPSC = '7315180000'
2) Based on condition of few fields of IIM
Example: IIM.IID <> 'IZ' AND IIM.IITYP = 'F' AND IIM.IVEND = 52
AND IIM.IWHS = 'OV'


Any reference will do much help for beginner like me.
Million Thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-16 : 04:44:18
We need to know the join conditions between the two tables.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Jasonyapkk
Starting Member

3 Posts

Posted - 2012-03-16 : 05:04:44
Miss this one.

Join condition is:
IIM.IPROD = IIMX.IXPROD
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-16 : 05:32:09
Try this:
update t1
set IXSPSC = '7315180000'
from IIMX as t1
join IIM as t2 on t2.IPROD = t1.IXPROD
where t2.IID <> 'IZ' AND t2.IITYP = 'F' AND t2.IVEND = 52
AND t2.IWHS = 'OV'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Jasonyapkk
Starting Member

3 Posts

Posted - 2012-03-18 : 23:04:31
Hi Webfred,

update t1
set IXSPSC = '7315180000'
from IIMX as t1
JOIN IIM as t2 on t2.IPROD = t1.IXPROD
WHERE t2.IID <> 'IZ' AND t2.IITYP = 'F' AND t2.IVEND = 52
AND t2.IWHS = 'OV'
Keyword FROM not expected. Valid tokens: SKIP WITH WHERE.

Not able to update as suggested above.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-19 : 03:30:41
Then you are not using MS SQL Server.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -