Link to home
Start Free TrialLog in
Avatar of catchup99
catchup99

asked on

Permissions to Databases in SSMS

How does the user access to all the databases from Master Database they have permissions to in Sql server Management Studio?
Avatar of pramodsk40
pramodsk40
Flag of United States of America image

you can have the user as sysadmin role which will have access to all databases. Or you want access other databases from Master db ?
Avatar of catchup99
catchup99

ASKER

I think im not clear with my question. I need a c# code to show all tables that i have permission to in Sql server Management studio
this is the SQL query that will tell you that.. can you plug this into C#
select name,
CanSelectAll = case when Permissions(id)&1 = 1 then 'Yes' else 'No' END ,
CanSelectAny = case when Permissions(id)&4096 = 4096 then 'Yes' else 'No' END ,
CanUpdateAll = case when Permissions(id)&2 = 2 then 'Yes' else 'No' END ,
CanUpdateAny = case when Permissions(id)&8192 = 8192 then 'Yes' else 'No' END ,
CanInsert = case when Permissions(id)&8 = 8 then 'Yes' else 'No' END ,
CanDelete = case when Permissions(id)&16 = 16 then 'Yes' else 'No' END , 
CanExecute = case when Permissions(id)&32 = 32 then 'Yes' else 'No' END
from sysobjects where type = 'U';

Open in new window

The above query doesn't give which user has permissions to table. Please help me with that.
ASKER CERTIFIED SOLUTION
Avatar of 25112
25112

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your response...Now i need to write an application in c# so that when the user login with their ID should display tables from sql that has access to and when clicked on particular table data should be displayed.
Any ideas?
catchup99, glad it worked for you.

This is the SQL Server Zone.. I would recommend posting the C# question in that zone for better responses. Since this is SQL zone, you are going to get help with SQL code not C# (as much)
Thanks again for your help..
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.