Curious interview question

  • On friday, I had a job interview and I was asked an interesting question. It was about querying and updating the registry using T-SQL. After the interview, I researched the question and found a possible answer using undocumented extended procedures.

    The reason for this post is to ask you've ever used this or does it adds any value in real life to know this.

    If possible, I like to avoid modifying the registry because I'm not knowledgeable enough to know how to do it by myself. But I wanted to know your opinion.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • i don't update the registry, but i have a lot of admin scripts that do things like read the registry data/log/backup folders from the registry, so i can use them for the creation of backup jobs and other stuff, like the destination folder for CLR functions that write to disk.

    the advantage is the registry functions are instance-specific, so on machines with multiple SQL instances, it helps enormously

    it's a solid tool in the tool box.

    EXECUTE [master].dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',

    N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',

    N'BackupDirectory';

    .

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • That's good to know. As I'm basically a developer, I'm not used to work on admin tasks.

    Thank you, Lowell.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • I've read/written from/to the registry for certain crazy imports back in the days of the JET drivers. I also use it to read the default backup directory paths that Lowell identified.

    As a bit of a sidebar, I think that such questions should not be asked during a Developer Interview for obvious reasons.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I have had to read from the registry when creating DTS (back in the day) and SSIS packages. Some app developers like to store information about that custom app in the registry.

    That does seem like a "out of left-field" kind of question. My experience has been that when people ask these kind of questions it's because it's something that they are doing there.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • Jeff Moden (2/3/2015)


    I think that such questions should not be asked during a Developer Interview for obvious reasons.

    +10

    I too have queried the registry for various things via tsql.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Lowell (2/3/2015)


    i don't update the registry, but i have a lot of admin scripts that do things like read the registry data/log/backup folders from the registry, so i can use them for the creation of backup jobs and other stuff, like the destination folder for CLR functions that write to disk.

    the advantage is the registry functions are instance-specific, so on machines with multiple SQL instances, it helps enormously

    it's a solid tool in the tool box.

    EXECUTE [master].dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',

    N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',

    N'BackupDirectory';

    .

    Yep, this. Although I think that info is now available in DMV's for newer versions of SQL (2012+ ?)

  • Gazareth (2/3/2015)


    Yep, this. Although I think that info is now available in DMV's for newer versions of SQL (2012+ ?)

    oh, i wish i was running pure 2012 and above...that would be sweet. I need to review some of the new stuff in the dmv's , thanks for the pointer!

    I'm happy i retired my last SQL2000 server last year (well the hardware under it died, so it kind of self retired and came off of my responsbilities list)

    my shop has most servers are running 2008R2, so scripts that need those directories will be using the xp's for the forseeable future. i have a few 2005's and a few 2012's, and a pair of SQL2014 (one production/ one Dev )

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (2/3/2015)


    Gazareth (2/3/2015)


    Yep, this. Although I think that info is now available in DMV's for newer versions of SQL (2012+ ?)

    oh, i wish i was running pure 2012 and above...that would be sweet. I need to review some of the new stuff in the dmv's , thanks for the pointer!

    I'm happy i retired my last SQL2000 server last year (well the hardware under it died, so it kind of self retired and came off of my responsbilities list)

    my shop has most servers are running 2008R2, so scripts that need those directories will be using the xp's for the forseeable future. i have a few 2005's and a few 2012's, and a pair of SQL2014 (one production/ one Dev )

    Hmm, think I'm a victim of my own wishful thinking here... seems reading the registry is still required in 2012/2014.

    Although it can be found via SMO if you're going that way.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply