Skip to content

Instantly share code, notes, and snippets.

@ghulamostafa
Created May 19, 2019 17:10
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 ghulamostafa/c90835b9afce89094849ff5b2e8e6b4e to your computer and use it in GitHub Desktop.
Save ghulamostafa/c90835b9afce89094849ff5b2e8e6b4e to your computer and use it in GitHub Desktop.
Given Access to a Specific User to a Specific Database
--Step 1: (create a new user)
CREATE LOGIN hello WITH PASSWORD='foo', CHECK_POLICY = OFF;
-- Step 2:(deny view to any database)
USE master;
GO
DENY VIEW ANY DATABASE TO hello;
-- step 3 (then authorized the user for that specific database , you have to use the master by doing use master as below)
USE master;
GO
ALTER AUTHORIZATION ON DATABASE::yourDB TO hello;
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment