Monday, October 24, 2016

How to query the Windows domain name for SQL Server

Yes.  There will come a time when you need to confirm the domain name of your server. Today, for example, I was setting up a bunch of RDP connections, and the domain name was a required credential.  This particular customer has several domains, so I just wanted to check quickly, to be sure I was targeting the right one.  I have posted 3 ways below, beginning with the easiest... which is the one I prefer to use!  Take a look and let me know if you have another way to do the same.

-- 1. Easiest
SELECT DEFAULT_DOMAIN() DomainName

-- 2. Also easy, but calling an xp
EXEC master..xp_loginconfig 'Default Domain'

-- 3. Way overkill, but it works
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 @Domain [DomainName]


Just a quick tip, but I know that some of you will find it helpful.  

21 comments:

  1. Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that. website design agency

    ReplyDelete
  2. This internet site is my aspiration, very excellent design and Perfect articles. web design agency

    ReplyDelete
  3. Hello! Wonderful post! Please when I could see a follow up! ui/ux

    ReplyDelete
  4. Wanted posting. Loads of excellent writing here. I wish I saw it found the site sooner. Congrats! ui/ux designer

    ReplyDelete
  5. Interesting post. I’ll be sticking around to hear much more from you guys. Thanks! design articles

    ReplyDelete
  6. choice. Anyhow; if you are a young driver and new to the road life, then you can certainly horn ui/ux designer

    ReplyDelete
  7. Satisfying posting. It would appear that a lot of the stages are depending upon the originality aspect. “It’s a funny thing about life if you refuse to accept anything but the best, you very often get it.” by W. Somerset Maugham.. ipad device template

    ReplyDelete
  8. I discovered your blog site site on the search engines and check several of your early posts. Always maintain up the very good operate. I recently additional increase Rss to my MSN News Reader. Looking for toward reading much more on your part later on!… ipad template

    ReplyDelete
  9. As soon as I found this internet site I went on reddit to share some of the love with them. macbook mockups

    ReplyDelete
  10. This is great content! I am swept away by your presentation and unique viewpoints. I agree with so much of your article. I’ll come back. android phone template
    This is great content! I am swept away by your presentation and unique viewpoints. I agree with so much of your article. I’ll come back. android phone template

    ReplyDelete
  11. This will be a terrific blog, would you be interested in doing an interview about just how you developed it? If so e-mail me! webflow agency

    ReplyDelete
  12. I have been exploring for a bit for any high quality articles or blog posts in this kind of space . Exploring in Yahoo I ultimately stumbled upon this web site. Studying this information So i am glad to show that I have a very excellent uncanny feeling I discovered just what I needed. I such a lot unquestionably will make sure to do not disregard this website and give it a look regularly. best web development company

    ReplyDelete
  13. How do I know if a Wordpress theme supports a subscribe option? web development agency

    ReplyDelete
    Replies
    1. Unfortunately, I cannot say. Possibly check out how they are configured in the WordPress Admin, or do some research here: https://www.wpbeginner.com/. Good luck!

      Delete
  14. I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post. cheap rdp

    ReplyDelete
  15. I’m not that much of a internet reader to be honest but your blogs really nice, keep it up! I’ll go ahead and bookmark your site to come back in the future. All the best.
    web design agency

    ReplyDelete
  16. Awesome and interesting article. Great things you've always shared with us. Thanks. Just continue composing this kind of post. renewing a domain name

    ReplyDelete
  17. What a post with wonderful explanation. I would like to visit your website often for the more posts. Keep it up.

    ReplyDelete