Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

T-SQL how can I get the name of the domain?

Status
Not open for further replies.

SteveMe

MIS
Aug 30, 2002
83
US
I know how to get the server name @@servename

But does anyone know how to get the domain name

Please advise. Thanks
 
select suser_sname()
select SYSTEM_USER

do you mean the logged on user domain?
 
What happens if I can't get the domain name from the suser_name?
 
In SQL 2000 you can use this
Code:
exec master.dbo.xp_ntsec_enumdomains

However this command isn't available in SQL 2005.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top