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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 sql Incorrect syntax near the keyword 'insert'.

Author  Topic 

vip
Starting Member

4 Posts

Posted - 2014-10-29 : 15:00:30

assume i have 2 tables table1(id,name,description,tid) table2(id(autoincrement),value)

update table1 set tid= insert into table2 values('x') SELECT @@IDENTITY AS id

the above command is giving me an error.

Can you suggest a solution??

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-10-29 : 16:02:10
What is your goal? Not quite clear from the statement that you have. Are you trying to insert something into table2, get the value that got inserted into the id column and update the tid column in table1 with that value? If that is the case, which row in table1 do you want to update?
Go to Top of Page
   

- Advertisement -