469,275 Members | 1,528 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

mssql 2000 update from select

I am trying to update a table from a select statement, any suggestions?

update (select column1 from table1)
set column2 = 'value'

The data in column1 contains the name of the table I want to update column2 with the 'value'.

I'm am pretty sure the syntax is in correct along with the structure. The error...

Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '('.
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near '='.
Jul 11 '07 #1
2 4958
ck9663
2,878 Expert 2GB
I am trying to update a table from a select statement, any suggestions?

update (select column1 from table1)
set column2 = 'value'

The data in column1 contains the name of the table I want to update column2 with the 'value'.

I'm am pretty sure the syntax is in correct along with the structure. The error...

Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '('.
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near '='.

nope, the syntax is not correct. in this case you have to build the string for the entire update command..

set @sqlcmd = 'update ...."

exec (@sqlcmd)
Jul 11 '07 #2
Please explain how to build.
Jul 11 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Guillaume | last post: by
7 posts views Thread by mj | last post: by
1 post views Thread by Philip Mette | last post: by
5 posts views Thread by Markon | last post: by
8 posts views Thread by Yusuf INCEKARA | last post: by
4 posts views Thread by AJA | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.