SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Checking database access


Checking database access

Author
Message
bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)

Group: General Forum Members
Points: 7857 Visits: 25280
Still a suprisingly low correct

Correct answers: 35% (100)
Incorrect answers: 65% (183)
Total attempts: 283



If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
mtassin
mtassin
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4834 Visits: 72518
L' Eomot Inversé (1/11/2012)
Nice and simple.

I'm very surprised there's only 34% correct so far, although I would expect the wiggle on whether no other user is connected to a db which is in single-user mode would catch a few who didn't think hard (it returns 1 if an attempt to connect would have succeeded, which makes it pretty obvous that it can't return 1 if someone else is connected in single user mode, but while Vulcans might always get something like that right us poor humans sometimes don't think hard enough), but that doesn't seem to account for enough of the wrong answers.


I got it wrong, because instead of BOL, I just used SSMS's SQL Help (2008 R2). For that I have


Remarks
HAS_DBACCESS returns 1 if the user has access to the database, 0 if the user has no access to the database, and NULL if the database name is not valid.




--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
Paul White
Paul White
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15834 Visits: 11355
L' Eomot Inversé (1/11/2012)
Nice and simple.

I see a lot of people saying this, but either my product knowledge is significantly below average or we're doing something differently. I don't, for example, check BOL before answering - I do it on the spot. That's not to say either way is right or wrong, just a potential point of difference.

I'm very surprised there's only 34% correct so far, although I would expect the wiggle on whether no other user is connected to a db which is in single-user mode would catch a few who didn't think hard (it returns 1 if an attempt to connect would have succeeded, which makes it pretty obvous that it can't return 1 if someone else is connected in single user mode, but while Vulcans might always get something like that right us poor humans sometimes don't think hard enough), but that doesn't seem to account for enough of the wrong answers.

This function is one I don't use much. I know what it does, but I hovered between single-user and suspect as the second option to the obvious first correct answer. I have no experience of executing HAS_DBACCESS against a single-user mode database or a suspect one, so I took a guess.

edit: I should add that I am unsure of the value of this question, beyond one that simply asked a 'nice and simple' question about what HAS_DBACCESS does in normal circumstances. I don't expect to remember the second correct option for any length or time, or that it would ever be important for me to do so. Overall: meh.



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
jeff.mason
jeff.mason
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1471 Visits: 2137
SQL Kiwi (1/11/2012)
L' Eomot Inversé (1/11/2012)
Nice and simple.

I see a lot of people saying this, but either my product knowledge is significantly below average or we're doing something differently. I don't, for example, check BOL before answering - I do it on the spot. That's not to say either way is right or wrong, just a potential point of difference.

I'm very surprised there's only 34% correct so far, although I would expect the wiggle on whether no other user is connected to a db which is in single-user mode would catch a few who didn't think hard (it returns 1 if an attempt to connect would have succeeded, which makes it pretty obvous that it can't return 1 if someone else is connected in single user mode, but while Vulcans might always get something like that right us poor humans sometimes don't think hard enough), but that doesn't seem to account for enough of the wrong answers.

This function is one I don't use much. I know what it does, but I hovered between single-user and suspect as the second option to the obvious first correct answer. I have no experience of executing HAS_DBACCESS against a single-user mode database or a suspect one, so I took a guess.

edit: I should add that I am unsure of the value of this question, beyond one that simply asked a 'nice and simple' question about what HAS_DBACCESS does in normal circumstances. I don't expect to remember the second correct option for any length or time, or that it would ever be important for me to do so. Overall: meh.


I agree on the "not so obvious". I also didn't use BOL but reasoned it like this -- you can't USE a DB when it is suspect and most of the time you have to USE a DB to run a function against it, so since you can't use a suspect DB you can't run this function against it. Obviously based upon the answer you must be able to run it against any DB regardless of connection context.
Andre Guerreiro
Andre Guerreiro
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1349 Visits: 1515
SQL Kiwi (1/11/2012)
This function is one I don't use much. I know what it does, but I hovered between single-user and suspect as the second option to the obvious first correct answer. I have no experience of executing HAS_DBACCESS against a single-user mode database or a suspect one, so I took a guess.


That's exactly what was on my mind and exactly the same answers I marked.

Best regards,

Best regards,

Andre Guerreiro Neto

Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2/MCSE/MCSA
Revenant
Revenant
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7375 Visits: 4864
Got this one wrong, but learned something...

Thanks, Steve!
OzYbOi d(-_-)b
OzYbOi d(-_-)b
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1348 Visits: 778
tks for the question
BarbW
BarbW
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3147 Visits: 1130
ARRGH! should read the WHOLE question and choose two! w00t
george sibbald
george sibbald
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10396 Visits: 13687
good question I think. Reminds people of the function (or brings it to their attention for the first time) so its educational, but steve put a little twist in it so you had to think and not just google it.

---------------------------------------------------------------------
rfr.ferrari
rfr.ferrari
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1537 Visits: 13628
Good question!!!

Thanks Steve!!!!!


rfr.ferrari
DBA - SQL Server 2008
MCITP | MCTS

remember is live or suffer twice!
the period you fastest growing is the most difficult period of your life!

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search