MSsql 中怎么删除数据库里某个用户所有表里的数据,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。-->Title:删除数据库里某个用户
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'')'
看完上述内容,你们掌握MSSQL 中怎么删除数据库里某个用户所有表里的数据的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注编程网数据库频道,感谢各位的阅读!
--结束END--
本文标题: MSSQL 中怎么删除数据库里某个用户所有表里的数据
本文链接: https://www.lsjlt.com/news/58899.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0