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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Return System Login Name

Author  Topic 

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-22 : 03:31:22
Dear Member

Any one know
How To retrieve local system login name with domain name in sql2005 ?

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-22 : 03:36:26
--This?

SELECT HOST_NAME() AS HostName, SUSER_NAME() LoggedInUser

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-22 : 03:46:54
you can use SYSTEM_USER also which is synonym for SUSER_NAME as per SQL-92 standards

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-22 : 03:57:57
thanks to reply

but this returns loggedinUser is sa

i want system login name when user is login his system
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-22 : 04:12:11
quote:
Originally posted by amirs

thanks to reply

but this returns loggedinUser is sa

i want system login name when user is login his system


You wont get that if user is using sql server authentication to connect to sql server.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2013-05-22 : 04:16:49
i want to local system login name
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2013-05-22 : 04:24:12
if you are using sql server authentication then sql server doesn't know who you are -- just which sql server account you logged in as.

Can you switch to windows authentication?
http://www.petri.co.il/how-to-choose-sql-server-authentication-mode.htm

Transact Charlie
Msg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
http://nosqlsolution.blogspot.co.uk/
Go to Top of Page
   

- Advertisement -