I am using MSSQL 2008 R2. I have a particular database that when it is restored it is being accessible from everyone from the SQL Management Studio. By using the below SQL statement I have identified that the Public server role has been granted the connect permission on this database.
use db_mydb
SELECT *
FROM sys.database_permissions
WHERE grantee_principal_id = (SELECT principal_id
FROM sys.server_principals
WHERE name ='public')
With the result of this query being the below
0 DATABASE 0 0 2 1 CO CONNECT G GRANT
Is there any work around to revoke this permission?
My solution for this was to create an empty database. Then script the tables, views and stored procuders using the Generate Scripts. And then import the data using the Import Data option. All of this can be done using only the Micosoft SQL Management Studio.