I'm using SQL Server. I want to create a stored procedure that truncates 3 of my tables (dbo.table1, dbo.table2, dbo.table3).
I want to clear out all of my tables this way. What am I missing?
CREATE PROCEDURE truncate_tables()
AS
truncate table dbo.table1
truncate table dbo.table2
truncate table dbo.table3
Remove () next to the stored procedure name. () required if you are passing any parameter to the SP.
Add ; in end of each TRUNCATE TABLE statement as query terminator.
CREATE PROCEDURE truncate_tables
AS
TRUNCATE TABLE dbo.table1;
TRUNCATE TABLE dbo.table2;
TRUNCATE TABLE dbo.table3;
You are missing BEGIN and END and semicolons:
CREATE PROCEDURE truncate_tables AS
BEGIN
truncate table dbo.table1;
truncate table dbo.table2;
truncate table dbo.table3;
END;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With