Skip to content

Instantly share code, notes, and snippets.

@anzekrpic
Created March 24, 2015 13:30
Show Gist options
  • Save anzekrpic/dbea72a0b0d4e7190b46 to your computer and use it in GitHub Desktop.
Save anzekrpic/dbea72a0b0d4e7190b46 to your computer and use it in GitHub Desktop.
Template for creating login and user
CREATE LOGIN [<SQL_login_name, sysname, login_name> ]
WITH PASSWORD = N'<password, sysname, Change_Password>';
GO
CREATE USER [<SQL_login_name, sysname, login_name> ] FOR LOGIN [<SQL_login_name, sysname, login_name> ] WITH DEFAULT_SCHEMA=[dbo]
GO
EXEC sp_addrolemember 'db_datareader', '<SQL_login_name, sysname, login_name> ';
EXEC sp_addrolemember 'db_datawriter', '<SQL_login_name, sysname, login_name> ';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment