Domanda

I have a script that creates a login in SQL Server as follows:

CREATE LOGIN [MyDomain\MyUser] FROM WINDOWS WITH DEFAULT_DATABASE=[master],
DEFAULT_LANGUAGE=[us_english]
GO

Is it possible to add to this script the granting of server roles? I want to grant the sysadmin server role to this user

È stato utile?

Soluzione

By using sp_addsvrrolemember stored procedure:

EXEC master..sp_addsrvrolemember @loginame = N'MyDomain\MyUser', @rolename = N'sysadmin'
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top