第一种方法:
复制代码 代码如下:
CREATE proc [dbo].[delAllRecord]
as
declare @tableName nvarchar(255)
declare @Sql nvarchar(255)
Declare curTable Cursor
for select Table_Name from information_schema.tables where TABLE_TYPE=’BASE TABLE’
Open curTable
Fetch Next From curTable Into @tableName
WHILE(@@FETCH_STATUS = 0)
BEGIN
set @Sql = N’delete from ‘+@tableName
exec sp_executesql @sql
Fetch Next From curTable Into @tableName
end
CLOSE curTable
DEALLOCATE curTable
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/tech/database/234434.html
赞 (0)