删除所有表数据

DECLARE @strSQL NVARCHAR(MAX)
SET @strSQL=''
 
SELECT @strSQL=@strSQL+' drop table ['+name +'];'
from sysobjects 
WHERE [type]='U' 

and (name like 'edi_%')
and name not in('EdiFinancialInterface','EdiFinancialInterfaceControl','EdiFinancialInterfaceDetail','EdiFinancialInterfaceMain')
--SELECT @strSQL

EXEC (@strSQL)

 

DECLARE @strSQL NVARCHAR(MAX)
SET @strSQL=''
 
SELECT @strSQL=@strSQL+' DELETE FROM ['+name +'] where 1=1;'
from sysobjects 
WHERE [type]='U' 

and (name like 'T%')
and name not in('Tunnel_RoadType','Road_PavementType','Bridge_ExpansionJointType','EdiFinancialInterfaceMain')


EXEC (@strSQL)

你可能感兴趣的:(删除所有表数据)