Is there any way to use a variable in an Insert statement?
I am trying to do the following:
INSERT INTO Employees
ID, LastName, FirstName
SELECT ID, Last, First FROM Employees2
WHERE (...)
I would like to be able to do this:
INSERT INTO @MyTableName
@MyField1, @myField2, @MyField3
SELECT ID, Last, First FROM Employees2
WHERE (...)
Is there any way to substitute th tablename with a variable,
so that this can be run in a loop if needed where the variable would change with each iteration of the loop?
It would also be cool to be able to substitute for the field names...
Thanks in advance!
I am trying to do the following:
INSERT INTO Employees
ID, LastName, FirstName
SELECT ID, Last, First FROM Employees2
WHERE (...)
I would like to be able to do this:
INSERT INTO @MyTableName
@MyField1, @myField2, @MyField3
SELECT ID, Last, First FROM Employees2
WHERE (...)
Is there any way to substitute th tablename with a variable,
so that this can be run in a loop if needed where the variable would change with each iteration of the loop?
It would also be cool to be able to substitute for the field names...
Thanks in advance!