create PROCEDURE [dbo].[TruncateTableWithFK]
(
@tableName nvarchar(200)
)
AS
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
--Delete the table
Declare @SQL varchar(2048)
SET @SQL = ' delete from '+ @tableName
Exec(@SQL)
--Reset identity column
IF EXISTS
(
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMNPROPERTY
(
OBJECT_ID( QUOTENAME(table_schema)+ '.' + QUOTENAME(@tableName) ),
column_name,'IsIdentity'
) = 1
)
DBCC CHECKIDENT(
@tableName
,RESEED,0)