I am dynamically creating tables in stored procedures, and would like to use variables for the table identifiers. Something like:
CREATE TABLE @TableName (
-- ...
But I always get a syntax error "near '@TableName'". I am currently concatenating an entire SQL string and running it with sp_executesql, but I suspect it bypasses much stored proc optimisation, which is what I want (the creation strings are fairly long).
Another developer told me it works for him, but I can't seem to get it to work. Any ideas/workarounds? I am running MSDE 2000, and using both ODBC and ADO.Net.
TIA
CREATE TABLE @TableName (
-- ...
But I always get a syntax error "near '@TableName'". I am currently concatenating an entire SQL string and running it with sp_executesql, but I suspect it bypasses much stored proc optimisation, which is what I want (the creation strings are fairly long).
Another developer told me it works for him, but I can't seem to get it to work. Any ideas/workarounds? I am running MSDE 2000, and using both ODBC and ADO.Net.
TIA