Skip to content

Instantly share code, notes, and snippets.

@Alexisvt
Last active April 13, 2018 16:11
Show Gist options
  • Save Alexisvt/d10969f84ffabf80ffc9854c451e2989 to your computer and use it in GitHub Desktop.
Save Alexisvt/d10969f84ffabf80ffc9854c451e2989 to your computer and use it in GitHub Desktop.
SQL query for create a sql user for the database
-- This file should execute in the database that you want to assign this user
CREATE USER webappuser
FOR LOGIN webappuser
GO
EXEC sp_addrolemember N'db_datareader', N'webappuser'
EXEC sp_addrolemember N'db_datawriter', N'webappuser'
EXEC sp_addrolemember N'db_ddladmin', N'webappuser'
GO
-- We need to execute this query in master database in order to assign it to others databases
CREATE LOGIN sampleuser WITH PASSWORD = 'yourpassword' GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment