SQLCMD Login/User create template

USE master
CREATE LOGIN [$(UserName)] FROM WINDOWS WITH DEFAULT_DATABASE=[$(DatabaseName)]
GO
USE [$(DatabaseName)]
GO
CREATE USER [$(UserName)] FOR LOGIN [$(UserName)]
GO
EXEC sp_addrolemember N'$(RoleName)', N'$(UserName)'
GO

Comments are closed.

Post Navigation