I have the following SQL code in a stored procedure:
CREATE PROCEDURE sp_createAColDiffTable (@table_name nvarchar(128))
AS
CREATE TABLE @table_name (
[table_name] VARCHAR (128) NOT NULL,
[column_name] VARCHAR (128) NULL,
[what_changed] VARCHAR (128) NULL,
[sr_data_type] VARCHAR (128) NOT NULL,
[tr_data_type] VARCHAR (128) NOT NULL,
[sr_max_length] SMALLINT NOT NULL,
[tr_max_length] SMALLINT NOT NULL,
[sr_is_nullable] CHAR NULL,
[tr_is_nullable] CHAR NULL,
[sr_precision] SMALLINT NULL,
[tr_precision] SMALLINT NULL,
[sr_scale] SMALLINT NULL,
[tr_scale] SMALLINT NULL )
ON [PRIMARY]
WITH (DATA_COMPRESSION = NONE)
I call the stored procedure like this:
EXEC [sp_createAColDiffTable] 'hq193.dbo.arch_con_col_s193_s202'
When I run the code I get the error:
Incorrect syntax near '@table_name'.
When I substitute the actual table name for @table_name
it works fine.
Can someone point out the problem with my syntax?