wsyeager
Well-known member
Im trying to insert data into a table that was created dynamiclly. Data will be inserted into several of these types of tables. I tried to substitute the tablename as a parameter, but got the following error when I tried to execute the query:
"Invalid object name @CDRTableName.
Here is my stored procedure. Notice I included the periods for brevity:
If I obviously hard code the parameter @CDRTableName, it works just fine.
How can I successfully construct the stored procedure in order to use the correct table name?
"Invalid object name @CDRTableName.
Here is my stored procedure. Notice I included the periods for brevity:
Code:
ALTER PROCEDURE [dbo].[InsertCDRSearchResults]
(
@BatchName varchar(50),
.
.
.
@CDRTableName varchar(20)
)
AS
INSERT INTO [@CDRTableName] ([BatchName], ..., [CDR_Version]) VALUES (@BatchName, ..., @CDR_Version);
If I obviously hard code the parameter @CDRTableName, it works just fine.
How can I successfully construct the stored procedure in order to use the correct table name?
Last edited by a moderator: