Member
152
Points
|
Replied on
30 Jul 2013 02:47 PM IST
CREATE PROCEDURE [dbo].[usp_Truncate_AllTables]
AS
BEGIN
SET NOCOUNT ON;
DECLARE @List NVARCHAR(MAX)
SELECT @List=COALESCE(@List+',','')+Name FROM sys.Tables WHERE name not IN('sysdiagrams')
SELECT @List=REPLACE(REPLACE(@List,',',',TRUNCATE TABLE '),',',';')
SELECT @List='TRUNCATE TABLE '+@List
SELECT @List
EXEC (@List)
SET NOCOUNT OFF;
END
|