I have a SQL Server 2008 database. The database has a stored procedure which receives two strings as parameters. One parameter is used to build a temp table which will usually only have 1 or 2 rows but theoretically could have more.
For each row in the temp table, I need to insert a row into a different table that consists of the other parameter and the contents of the temp table. Is there a way to do this without a cursor?
I’ve tried variations on the following:
Pseudo code:
procedure InsertLinks(@Key varchar(36), @LinkKey varchar(36)
tempLinks Table = getLinks(@LinkKey)
Insert into MyTable (Key, LinksTo) Values (@Key, Select LinksTo From tempLinks)
The
VALUESclause is messed up – you have a single value comma a table. That’s not valid.The following should work just fine: