Find Domain Name Using T-SQL | SansSQL

Monday, November 17, 2008

Find Domain Name Using T-SQL

DECLARE @Domain varchar(100), @key varchar(100)

SET @key = 'SYSTEM\ControlSet001\Services\Tcpip\Parameters\'
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key=@key,@value_name='Domain',@value=@Domain OUTPUT
SELECT 'Server Name: '+@@servername + ' Domain Name:'+convert(varchar(100),@Domain)

Alternative ways,
1. SELECT DEFAULT_DOMAIN()
2. EXEC Master.dbo.xp_LoginConfig 'Default Domain'

22 comments:

Anonymous said...

Worked for me. Thank you.
(Nice site)

Paul Goldy said...

Thanks Sandesh. Very helpful SQL.

Paul Goldy said...

Thanks Sandesh. Very helpful SQL.

ArdentAj said...

When I tried this query it is throwing up Access Denied error.I think DBA haven't granted access for registry variables.

So is there any another way I can get Full computer name

Sandesh Segu said...

You can try either of the below queries

SELECT DEFAULT_DOMAIN()

EXEC Master.dbo.xp_LoginConfig 'Default Domain'

mtom said...

I do trust all of the ideas you’ve introduced for your post. They’re very convincing and will definitely work. Still, the posts are very short for beginners. May you please prolong them a bit from next time? Thank you for the post. Premium Domains

WebCodexIT said...

Gnarly article mate, keep the good work, just shared this with ma friendz website design company

WebCodexIT said...

I’m really impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it is rare to see a great blog like this one these days.. top web design companies

Alexander Albert said...

just couldn’t leave your web site before suggesting that I really loved the standard information a person provide for your visitors? Is gonna be again ceaselessly to check up on new posts web design

jacob olivia said...

Hi there! Do you use Twitter? I’d like to follow you if that would be ok. I’m undoubtedly enjoying your blog and look forward to new posts. web designer

khanabaaz said...

I totally understand what you have explained. Actually, I browsed throughout your several other content articles and I do believe you are absolutely correct. Congrats with this particular blog. ipad psd

Unknown said...

Hey i’m for the first time here. I came across this board and I find It seriously helpful & it helped me out much. I hope to give something back and aid others as you aided me. android phone template

relxindo said...

I like this website very much, Its a very nice post to read and find information. naveed ahmed poetry

Mark weins said...

Loving the information on this site, you have done outstanding job on the content . webflow design agency

Stream Line said...

Subsequently, after spending many hours on the internet at past We’ve uncovered anyone that certainly does know what they are discussing thank you very much wonderful blog post webflow experts

Unknown said...

I am impressed with this website , rattling I am a fan . webflow developers

Unknown said...

wonderful post. Ne’er knew this, regards for letting me know. webflow company

Hetuwa Duminda said...

I like this website because so much useful material on here : D. web developer company

mtom said...

After study several of the blog articles for your internet site now, and i also genuinely such as your strategy for blogging. I bookmarked it to my bookmark internet site list and are checking back soon. Pls take a look at my web page in addition and tell me what you believe. nba중계



----------------------------------------------------------------------------------------------------------------------------


Wow, superb blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is magnificent, as well as the content! mlb중계

sdexter said...

After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think. ui/ux design agency

sdexter said...

Thank you for an additional great post. Exactly where else could anybody get that kind of facts in this kind of a ideal way of writing? I have a presentation next week, and I’m around the appear for this kind of data. ui ux design

seo said...

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. renewing a domain name

Post a Comment

Ads