create-sqlserver-login-and-database.sql 741 B

123456789101112131415161718192021222324
  1. -- This SQL Server T-SQL script creates the database user and hello_world database.
  2. --
  3. -- To run this script, login to an administrator account in Windows, open a command prompt and run:
  4. --
  5. -- "%ProgramFiles%\Microsoft SQL Server\110\Tools\binn\sqlcmd.exe" -i <filename of this file>
  6. --
  7. -- This password has mixed-case and a number to satisfy the Windows password policy
  8. CREATE LOGIN benchmarkdbuser WITH PASSWORD = 'B3nchmarkDBPass'
  9. GO
  10. IF EXISTS(SELECT * FROM SYS.DATABASES WHERE NAME='hello_world')
  11. DROP DATABASE hello_world
  12. GO
  13. CREATE DATABASE hello_world
  14. GO
  15. USE hello_world
  16. GO
  17. -- Give this user total power over the database
  18. CREATE USER benchmarkdbuser FOR LOGIN benchmarkdbuser
  19. EXEC sp_addrolemember 'db_owner', 'benchmarkdbuser'
  20. GO