Results 1 to 9 of 9

Thread: So You Wanna Be An SQL Server DBA...

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    So You Wanna Be An SQL Server DBA...

    If so, then here is an article worth taking a moment to read.

    http://www.databasejournal.com/featu...61/article.htm

    I'm not the least bit interested in becoming a DBA, but I did find one note worthy thing...I have been writing "correlated sub queries" for years and did not know that is what they are called?

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: So You Wanna Be An SQL Server DBA...

    Yep, they're even called that in Jet databases. From the MSDN Library:
    Intermediate Microsoft Jet SQL for Access 2000

    The EXISTS subquery

    The EXISTS predicate is used in subqueries to check for the existence of values in a result set. In other words, if the subquery does not return any rows, the comparison is False. If it does return one or more rows, the comparison is True.

    Code:
    SELECT *
       FROM tblCustomers AS A
       WHERE EXISTS
       (SELECT * FROM tblInvoices
       WHERE A.CustomerID = tblInvoices.CustomerID)
    Note that in the previous SQL statement an alias is used on the tblCustomers table. This is so that we can later refer to it in the subquery. When a subquery is linked to the main query in this manner, it is called a correlated query.

  3. #3
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: So You Wanna Be An SQL Server DBA...

    I am interested, to start
    Please mark you thread resolved using the Thread Tools as shown

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: So You Wanna Be An SQL Server DBA...

    But as a DBA the question should be what is there any thing wrong with using correlated sub queries? What if the result set is large?
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: So You Wanna Be An SQL Server DBA...

    Quote Originally Posted by Hack View Post
    If so, then here is an article worth taking a moment to read.

    http://www.databasejournal.com/featu...61/article.htm

    I'm not the least bit interested in becoming a DBA, but I did find one note worthy thing...I have been writing "correlated sub queries" for years and did not know that is what they are called?
    Ahh, so that's what it's called. Yeah, I've been doing that for years too. Now I've lost my innocence!

    No ... I wouldn't want to be a DBA either. Seems to me to be too much like herding cats.

    http://www.youtube.com/watch?v=VrlV-cG35nI

    -Max
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

  6. #6
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: So You Wanna Be An SQL Server DBA...

    If you want to be a DBA then this song is worth remembering.

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: So You Wanna Be An SQL Server DBA...

    in 20+ years, I had never encountered correlated queries until my current employment. Quite frankly, they confuse me and aren't intuitive.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: So You Wanna Be An SQL Server DBA...

    I use them but they really need to be thought about. Would you want to run the correlated query (which runs against every row) if you were pulling a record set with millions of rows? I would say this would be a problem.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: So You Wanna Be An SQL Server DBA...

    I'm going to go out on a limb here and suggest that the correlated query - in an EXISTS() function - never returns any rows. It just makes it as far as the INDEX SEEK/SCAN or TABLE SCAN - finds that a row exists - and then it's job is done.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width