DaveJunior
Programmer
Hi, I am a quite new at SQL and wondered if someone could give me a hand...
I am trying to pass the table name that I am searching through into a stored procedure as a variable however it gives me the error message: "The variable name '@TheTable' has already been declared. Variable names must be unique within a query batch or stored procedure." Any ideas? The code I am using is:
I am calling it like:
Any help would be great, cheers.
I am trying to pass the table name that I am searching through into a stored procedure as a variable however it gives me the error message: "The variable name '@TheTable' has already been declared. Variable names must be unique within a query batch or stored procedure." Any ideas? The code I am using is:
Code:
CREATE PROC Forum__CheckNoOfReplies @TheTable varchar(100), @TheID int(4) As
SELECT AllowedReplies
FROM @TheTable
WHERE ID = @TheID
GO
I am calling it like:
Code:
EXEC CheckNoOfReplies 'Forum_Classfieds', '54'
Any help would be great, cheers.