I am using SQL Server 2008.
The following is part of a stored procedure. The @Param1 –> @Param6 are the stored procedures parameters.
This is what I am trying to do:
INSERT INTO myTable
VALUES (otherTableValue, @Param2, @Param3, @Param4, @Param5)
SELECT ID as otherTableValue
FROM otherTable
WHERE otherTable.Param6 = @Param6
I am getting “invalid column name” as an error. What am I doing wrong?
Your syntax is wrong. To use a
selectin aninsert, you use theselectinstead of thevalues: