|
ForEach cursor global for select ''''''''['''''''' + REPLACE(user_name(uid), N'''''''']'''''''', N'''''''']]'''''''') + '''''''']'''''''' + ''''''''.'''''''' + ''''''''['''''''' +
REPLACE(object_name(id), N'''''''']'''''''', N'''''''']]'''''''') + '''''''']'''''''' from dbo.sysobjects o '''' + N'''' where OBJECTPROPERTY(o.id, N''''''''''''+@isobject+'''''''''''') = 1 ''''+N'''' and o.category & '''' + @mscat + N'''' = 0 '''' + @whereand)
declare @retval int select @retval = @@error if (@retval = 0) exec @retval = sp_MSforeach_worker @command1, @replacechar, @command2, @command3
if (@retval = 0 and @postcommand is not null) exec(@postcommand)
return @retval
GO 这样我们来测试一下: 1.获得所有的存储过程的脚本: EXEc sp_MSforeachObject @command1="sp_helptext ''''?'''' ",@objectType=4 2.获得所有的视图的脚本: EXEc sp_MSforeachObject @command1="sp_helptext ''''?'''' ",@objectType=2 3.比如在开发过程中,没一个用户都是自己的OBJECT OWNER,所以在真实的数据库时都要改为DBO: EXEc sp_MSforeachObject @command1="sp_changeobjectowner ''''?'''', ''''dbo''''",@objectType=1 EXEc sp_MSforeachObject @command1="sp_changeobjectowner ''''?'''', ''''dbo''''",@objectType=2 EXEc sp_MSforeachObject @command1="sp_changeobjectowner ''''?'''', ''''dbo''''",@objectType=3 EXEc sp_MSforeachObject @command1="sp_changeobjectowner ''''?'''', ''''dbo''''",@objectType=4 这样就非常方便的将每一个数据库对象改为DBO.
当然还要很多非常好的功能,大家可以自己深入研究吧:-)
上一页 [1] [2] [聊天工具]企业邮件系统的利器----FoxMail Server [系统软件]OPEN SERVER 5.0.5安装EXP300阵列柜 [系统软件]关于Windows2000Server的灾难恢复 [常用软件][网络]下载服务革命性风暴Poco Server评测 [C语言系列]动态创建SQL Server数据库、表、存储过程等架构信… [C语言系列]SQL Server到DB2连接服务器的实现 [C语言系列]SQL Server到SYBASE连接服务器的实现 [C语言系列]SQL Server到SQLBASE连接服务器的实现 [C语言系列]SQL Server连接VFP数据库的实现 [C语言系列]ASP+SQL Server之图象数据处理
|