Guest User

Untitled

a guest
Mar 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. --Step 1: (create a new user)
  2. create LOGIN hello WITH PASSWORD='foo', CHECK_POLICY = OFF;
  3.  
  4.  
  5. -- Step 2:(deny view to any database)
  6. USE master;
  7. GO
  8. DENY VIEW ANY DATABASE TO hello;
  9.  
  10.  
  11. -- step 3 (then authorized the user for that specific database , you have to use the master by doing use master as below)
  12. USE master;
  13. GO
  14. ALTER AUTHORIZATION ON DATABASE::yourDB TO hello;
  15. GO
  16.  
  17. USE [yourDB]
  18. CREATE USER hello FOR LOGIN hello WITH DEFAULT_SCHEMA=[dbo]
  19. GO
  20.  
  21. USE yourDB;
  22. GO
  23. DROP USER newlogin;
  24. GO
  25.  
  26. USE master
  27. go
  28. DENY VIEW ANY DATABASE TO [user]
  29. go
Add Comment
Please, Sign In to add comment