I am trying to write a stored procedure in SQL2000 which will be called from an ASP.NET webpage. The procedure needs to create a table but as the name of the table varies I need to pass it as a parameter. The code I am trying to use is as follows:-
CREATE PROCEDURE XX_SamTest
@UserCode char(52), @SelectString char(1024)
AS
IF OBJECT_ID(@UserCode) IS NOT NULL
DROP TABLE @UserCode
CREATE TABLE @UserCode (
[CodeId] [uniqueidentifier]...............)
but the DROP and CREATE TABLE commands get rejected with a syntax error.
Can anyone advise on the correct syntax for this? Many thanks.
CREATE PROCEDURE XX_SamTest
@UserCode char(52), @SelectString char(1024)
AS
IF OBJECT_ID(@UserCode) IS NOT NULL
DROP TABLE @UserCode
CREATE TABLE @UserCode (
[CodeId] [uniqueidentifier]...............)
but the DROP and CREATE TABLE commands get rejected with a syntax error.
Can anyone advise on the correct syntax for this? Many thanks.