Skip to content

Instantly share code, notes, and snippets.

@mmacphail
Last active December 20, 2017 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmacphail/cd63fd52a86742577d39deda0403e856 to your computer and use it in GitHub Desktop.
Save mmacphail/cd63fd52a86742577d39deda0403e856 to your computer and use it in GitHub Desktop.
Remove a table from SQL Server and remap user
use master
ALTER DATABASE [db] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
IF EXISTS (SELECT * FROM sysdatabases WHERE name=N'db' ) DROP DATABASE [db]
create database db
use elis_work
create user user from login user
exec sp_addrolemember 'db_owner', 'user'
ALTER DATABASE [db] SET MULTI_USER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment