Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Return System Login Name
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

amirs
Constraint Violating Yak Guru

India
260 Posts

Posted - 05/22/2013 :  03:31:22  Show Profile  Reply with Quote
Dear Member

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

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 05/22/2013 :  03:36:26  Show Profile  Reply with Quote
--This?

SELECT HOST_NAME() AS HostName, SUSER_NAME() LoggedInUser

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 05/22/2013 :  03:46:54  Show Profile  Reply with Quote
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

India
260 Posts

Posted - 05/22/2013 :  03:57:57  Show Profile  Reply with Quote
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

India
52326 Posts

Posted - 05/22/2013 :  04:12:11  Show Profile  Reply with Quote
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

India
260 Posts

Posted - 05/22/2013 :  04:16:49  Show Profile  Reply with Quote
i want to local system login name
Go to Top of Page

Transact Charlie
Flowing Fount of Yak Knowledge

United Kingdom
3451 Posts

Posted - 05/22/2013 :  04:24:12  Show Profile  Visit Transact Charlie's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000