Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
magikminox
Starting Member
27 Posts |
Posted - 2008-07-23 : 01:22:54
|
| HiIs there a way of checking if a user has access to a database before they connect or select from it.i.e i want to know if a user has access to a database before they try to access it so that if they dont,the query stops and continues to the next step. |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-23 : 03:25:44
|
| Check the sysusers table. If you are using windows authentication & windows groups you'll need to go to active directory. |
 |
|
|
magikminox
Starting Member
27 Posts |
Posted - 2008-07-23 : 05:01:41
|
| i have tried this and am still getting this erreor :server user id 333 is not valid user for database if exists (select name from db1..sysusers where name = suser_name()) begin declare @Flag bit select @Flag = (select reset_flag from db1.dbo.tbl_reset_flag where username = suser_name()) select @Flag,suser_name() end else begin print'user does not exist' |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-07-23 : 08:12:37
|
| If user don't have access to DB, then they won't be able to see or connect.sp_helplogins 'User' |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-07-23 : 23:49:29
|
| User still can see sql server even without login in it. |
 |
|
|
|
|
|