我想将Biztalk应用程序用户组的访问权限授予SQL Server数据库
use[mydatabase]
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = (select @@SERVERNAME)+N'\BizTalk Application Users')
BEGIN
CREATE USER [Domain\BizTalk Application Users']FOR LOGIN [Domain\BizTalk Application Users]
END;
GO
ALTER USER [Domain\BizTalk Application Users] WITH DEFAULT_SCHEMA=[dbo]
ALTER ROLE [db_roleAppUser] ADD MEMBER [Domain\BizTalk Application Users]
GO
我想用select @@SERVERNAME
替换我的域名,以便我可以在部署框架中运行此脚本。
有什么想法吗?
答案 0 :(得分:0)
DECLARE @login NVARCHAR(50),@sql NVARCHAR(max);
SET @login = (SELECT @@SERVERNAME)+N'\BizTalk Application Users'
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = (SELECT @@SERVERNAME)+N'\BizTalk Application Users')
BEGIN
SET @sql = N'CREATE USER [' + @login + N'] FOR LOGIN [' + @login + N'];'
EXEC sp_executesql @sql
END;
GO
DECLARE @login NVARCHAR(50),@sql NVARCHAR(max);
SET @login = (SELECT @@SERVERNAME)+N'\BizTalk Application Users'
SET @sql = N'ALTER USER [' + @login + N'] WITH DEFAULT_SCHEMA=[dbo]'
EXEC sp_executesql @sql
GO
DECLARE @login NVARCHAR(50),@sql NVARCHAR(max);
SET @login = (SELECT @@SERVERNAME)+N'\BizTalk Application Users'
SET @sql = N'ALTER ROLE [db_roleAppUser] ADD MEMBER [' + @login + N']'
EXEC sp_executesql @sql
GO