您现在的位置是:网站首页> 编程资料编程资料
MSSQL 删除数据库里某个用户所有表里的数据_MsSql_
2023-05-26
326人已围观
简介 MSSQL 删除数据库里某个用户所有表里的数据_MsSql_
-->Title:删除数据库里某个用户所有表里的数据
-->Author:wufeng4552
-->Date :2009-09-21 15:08:41
--方法1
declare @uname varchar(20)
declare cuser cursor for
select so.name
from sysobjects so,sysusers su where so.uid=su.uid and su.name='Stone'
and so.xtype='U'
open cuser
fetch next from cuser into @uname
while(@@fetch_status=0)
begin
exec('truncate table [Stone].['+@uname+']')
fetch next from cuser
end
close cuser
deallocate cuser
--方法2
exec sp_msforeachtable @command1="truncate table ? ;",@whereand='and schema_id = (select schema_id from sys.schemas where [name] =''Stone'')'
-->Author:wufeng4552
-->Date :2009-09-21 15:08:41
--方法1
复制代码 代码如下:
declare @uname varchar(20)
declare cuser cursor for
select so.name
from sysobjects so,sysusers su where so.uid=su.uid and su.name='Stone'
and so.xtype='U'
open cuser
fetch next from cuser into @uname
while(@@fetch_status=0)
begin
exec('truncate table [Stone].['+@uname+']')
fetch next from cuser
end
close cuser
deallocate cuser
--方法2
复制代码 代码如下:
exec sp_msforeachtable @command1="truncate table ? ;",@whereand='and schema_id = (select schema_id from sys.schemas where [name] =''Stone'')'
相关内容
- sqlserver 常用存储过程集锦_MsSql_
- sqlserver 中ntext字段的批量替换(updatetext的用法)_MsSql_
- MSSQL汉字转拼音函数实现语句_MsSql_
- union组合结果集时的order问题_MsSql_
- sqlserver 多表关联时在where语句中慎用trim()方法_MsSql_
- 目前用到的两个分页存储过程代码_MsSql_
- 远程连接局域网内的sql server 无法连接 错误与解决方法_MsSql_
- sqlserver 通用分页存储过程_MsSql_
- 批量更新数据库所有表中字段的内容,中木马后的急救处理_MsSql_
- Sql Server 2000删除数据库备份文件_MsSql_
