SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update Query in SQL Server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

djs42
Starting Member

Canada
4 Posts

Posted - 06/25/2013 :  20:26:34  Show Profile  Reply with Quote
I'm attempting to update data in a SQL Server table that I'm importing from another application. I have multiple fields that I want to update.

Matching would be something like this:
UPDATE A
set A.Item10 = B.Item10,
set A.Item11 = B.Item11,
set A.Item12 = B.Item12,
...
set A.Item28 = B.Item28
WHERE A.Number = B.PartNo

How do I accomplish this in SQL Server?

James K
Flowing Fount of Yak Knowledge

3712 Posts

Posted - 06/25/2013 :  20:43:30  Show Profile  Reply with Quote
quote:
Originally posted by djs42

I'm attempting to update data in a SQL Server table that I'm importing from another application. I have multiple fields that I want to update.

Matching would be something like this:
UPDATE A
set A.Item10 = B.Item10,
set A.Item11 = B.Item11,
set A.Item12 = B.Item12,
...
set A.Item28 = B.Item28
WHERE A.Number = B.PartNo

How do I accomplish this in SQL Server?

UPDATE A set 
	A.Item10 = B.Item10,
	A.Item11 = B.Item11,
	A.Item12 = B.Item12,
	...
	A.Item28 = B.Item28
from 
	YourDestinationTable A
	inner join YourSourceTable B on 
		A.Number = B.PartNo
Go to Top of Page

djs42
Starting Member

Canada
4 Posts

Posted - 06/25/2013 :  23:20:08  Show Profile  Reply with Quote
Tried this in a View in SSMSE, I get the Syntax error:

This SQL statement type cannot be used in a view or function.
Only a SELECT statement can be used.

Any ideas?


Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17645 Posts

Posted - 06/26/2013 :  00:33:20  Show Profile  Reply with Quote
quote:
Originally posted by djs42

Tried this in a View in SSMSE, I get the Syntax error:

This SQL statement type cannot be used in a view or function.
Only a SELECT statement can be used.

Any ideas?




Why are you doing this in a View ? Execute it in a query window


KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000