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 |
djs42
Starting Member
4 Posts |
Posted - 2013-06-25 : 20:26:34
|
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 Aset A.Item10 = B.Item10,set A.Item11 = B.Item11,set A.Item12 = B.Item12,...set A.Item28 = B.Item28WHERE A.Number = B.PartNoHow do I accomplish this in SQL Server? |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-06-25 : 20:43:30
|
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 Aset A.Item10 = B.Item10,set A.Item11 = B.Item11,set A.Item12 = B.Item12,...set A.Item28 = B.Item28WHERE A.Number = B.PartNoHow 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.Item28from YourDestinationTable A inner join YourSourceTable B on A.Number = B.PartNo |
|
|
djs42
Starting Member
4 Posts |
Posted - 2013-06-25 : 23:20:08
|
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? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-06-26 : 00:33:20
|
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[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|
|
|