June 10, 2014 at 11:09 pm
Comments posted to this topic are about the item Status and Name Please
June 10, 2014 at 11:10 pm
Good one, Andy. Thank you.
---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
June 11, 2014 at 12:02 am
Great question, I liked this one, definitly learnt somthing new 2day about those SUSER_SNAME() & USER_NAME() functions, Thanx Andy.
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
June 11, 2014 at 12:17 am
Yet another great question thanks.
The page USER_NAME (Transact-SQL) does mention that dbo is returned for sysadmins in example B.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 11, 2014 at 12:33 am
I need to study more about USER_NAME() and SUSER_SNAME() functions
Thanks
June 11, 2014 at 12:35 am
Good question, and I agree with Koen. The help page at http://technet.microsoft.com/en-us/library/ms188014.aspx does tell you that dbo is returned for members of sysadmin.
Here is the result set for a user that is a member of the sysadmin fixed server role.
------------------------------
dbo
June 11, 2014 at 12:41 am
It is nice way to learn new things.Thanks Andy.
--rhythmk
------------------------------------------------------------------
To post your question use below link
https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
🙂
June 11, 2014 at 6:05 am
Nice question, Andy. Good way to wake up the brain in the morning. Thanks.
June 11, 2014 at 7:04 am
Fun questions, thanks!
Be still, and know that I am God - Psalm 46:10
June 11, 2014 at 7:33 am
About the assumption, I'm not sure it was good to have in the answer, because the question had "You're the DBA with sysadmin access". But thinking beyond that, sometimes I want readers to infer things about the question. That makes it harder, more interesting, and less of a pure test taking skill question (maybe). Is infer better than assume? "This question depends on the reader correctly inferring..." vs "This question depends on the reader correctly assuming...". Reading those two, I think I do like infer better, as it does point toward derived knowledge and not just "I'm doing the SSC question of the day which means I'm an SA".
June 11, 2014 at 8:32 am
This was removed by the editor as SPAM
June 11, 2014 at 8:32 am
Great question. Easy and containing knowledge.
Did not like this part of the explanation -
The help page at http://technet.microsoft.com/en-us/library/ms188014.aspx doesn't tell you that though.
The current online help page for this SQL function is here:
How can I prove that this is the page that MS considers the current documentation? Happy you asked.
Open SSMS, Type in "SELECT USER_NAME()", put the cursor before the U in the function name then press the shift and F1 keys at the same time. The correct and current online help for the function in the version of SQL you are working with should appear before your eyes.
Don't be misinformed by reading poor documentation found using an incorrect method. Google is not always your friend. Friends don't let friends follow links to bad documentation.
Shift F1 works, let's keep it that way. Use it.
June 11, 2014 at 9:21 am
My results were different. e.g.
USE MASTER
GO
SELECT SUBSTRING('NY', is_read_only + 1, 1)
, USER_NAME()
FROM sys.databases
WHERE name = DB_NAME()
gives me:
(No column name)(No column name)
N guest
In a database where I am an owner, I get:
NUS\brittog
The second column is my login id.
June 11, 2014 at 9:31 am
PhyData, I take your point on that, I wish I had found a better reference for the answer. Shift F1 probably relevant more for QOTD than real life? I'll have to experiment, see if I want to retrain myself for work related searches or not.
June 11, 2014 at 10:45 am
Andy Warren (6/11/2014)
PhyData, I take your point on that, I wish I had found a better reference for the answer. Shift F1 probably relevant more for QOTD than real life? I'll have to experiment, see if I want to retrain myself for work related searches or not.
I had to change this post. The 2014 SQL server documentation does not have this wonderful piece of information that has been in every other version of the documentation.
The following example finds the name of the current user without specifying an ID.
SELECT USER_NAME();
GO
Here is the result set for a user that is a member of the sysadmin fixed server role.
------------------------------
dbo
Apparently it is a thing now to make every new version of the T-SQL documentation more lightweight than the last.
Marvelous! :sick: I mean UseLess!!
Viewing 15 posts - 1 through 15 (of 23 total)
You must be logged in to reply to this topic. Login to reply