Disable users of a database not Logins in SQL server 2008

Multi tool use
Multi tool use


Disable users of a database not Logins in SQL server 2008



To disable users of a Database in SQL Server 2008, I gave the command:


Use Database
Go
Revoke Connect from username;



It works for the users with SQL Server Authentication such as abcdef.



But not for the user with Windows Authentication such as DomainNameabcdef. It gives the error:



Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ''.



It does not even work by using the single quotes around the username in the above mentioned command.



Please suggest.




2 Answers
2



It worked when I used the double quotes around the username such as:


use Database
Go
Revoke Connect from "DomainNameabcdef"



To enable users of a database:


Use Database
Go
Grant Connect to "username"



To disable Logins of a server:


Use master
Go
Alter Login loginname disable;



To enable Logins of a server:


Use master
Go
Alter Login loginname enable;





That presumably requires QUOTED_IDENTIFIER ON. Using the SQL Server quotes of square brackets [like this] would work already without requiring that.
– underscore_d
Jul 2 at 11:05



QUOTED_IDENTIFIER ON


[like this]



I identify the disabled users by using the sys.sysusers DMV



you can see on the example below. the result of the query, and further below, navigating through ssms.


select * from sys.sysusers
where islogin =1
and hasdbaccess = 0



enter image description here



enter image description here





The question is how to disable Windows-authenticated users, not how to identify already-disabled users.
– underscore_d
Jul 2 at 11:06






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

4IV7E Dr,tmrtyU6dfxM,XA9iezy9EBq5hlYt9NR8xj78EQYdtaN8n3hrjHkv7,zKBbxHOB lcJm3A1RJeq9j
R,EK9y5 u30TVJ,1y5s,mCtAFdOFCXHvFKTu,Ax,wbWg6Q31rYp4fjHhlH,pX6cK0Af,ijqHL0lUOr,2Nb

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications