I’m quite new to SQL and I’m not sure why the following code is producing the error in title:
CREATE PROCEDURE Truncate (@table varchar(50))
AS
BEGIN
SET NOCOUNT ON;
EXEC ('TRUNCATE TABLE ' + @table);
END
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since Truncate is a reserved word, you cannot use it in the procedure name unquoted. You can do this:
But when you run it, you’ll have to say
Alternatively change the name of the procedure to TruncateTable:
then you can call it as