我创建了一些应用程序角色,并自动创建了以下SQL Server数据库:
declare @idx as int
declare @randomPwd as nvarchar(64)
declare @rnd as float
select @idx = 0
select @randomPwd = N''
select @rnd = rand((@@CPU_BUSY % 100) + ((@@IDLE % 100) * 100) +
(DATEPART(ss, GETDATE()) * 10000) + ((cast(DATEPART(ms, GETDATE()) as int) % 100) * 1000000))
while @idx < 64
begin
select @randomPwd = @randomPwd + char((cast((@rnd * 83) as int) + 43))
select @idx = @idx + 1
select @rnd = rand()
end
declare @statement nvarchar(4000)
select @statement = N'CREATE APPLICATION ROLE [AppRole_01] WITH DEFAULT_SCHEMA = [AppRole_01], ' + N'PASSWORD = N' + QUOTENAME(@randomPwd,'''')
EXEC dbo.sp_executesql @statement
GO
现在我看到这里有 EXEC dbo.sp_executesql @statement
,但我不理解它是什么意思。
- 为什么要调用这个存储过程?
- 我已经在数据库服务器上搜索了一遍,没有发现任何名为
sp_executesql
的存储过程,特别是dbo.sp_executesql
有没有人可以指导我解决这个问题?
[master]
中的系统扩展过程。 - RBarryYoung