SQLAuthority News – Happy New Year – 5 SQL New Year Resolutions

Happy New Year to All of YOU!

Let us start year 2009 with word of wisdom from Albert Einstein.

I feel that you are justified in looking into the future with true assurance, because you have a mode of living in which we find the joy of life and the joy of work harmoniously combined. Added to this is the spirit of ambition which pervades your very being, and seems to make the day’s work like a happy child at play. – Albert Einstein

“May this new year all your dreams turn into reality and all your efforts into great achievements.”

Every new year we all make resolutions and some follow it and some forget as times goes by. I suggest that this year we all together follow SQL 5 best practices resolutions.They are very easy and very simple but if you follow them I promise that next year at this time you will be for sure in thanking yourself.

  1. Use JOIN syntax instead of using comma separate tables in FROM clause.
    Correct Syntax :
    SELECT
    *
    FROM TableName T
    INNER JOIN TableName2 T2 ON T.Col = T2.Col

    Incorrect Syntax : SELECT * FROM TableName T, TableName2 T2 WHERE T.Col = T2.Col
  2. Always alias table and use alias as prefix to column name.
    Correct Syntax :
    SELECT T.Col, T2.Col1
    FROM TableName T
    INNER JOIN TableName2 T2 ON T.Col = T2.Col

    Incorrect Syntax : SELECT Col, Col1 FROM TableName T INNER JOIN TableName2 T2 ON T.Col = T2.Col
  3. A table should contain at least one Primary Key and one Clustered Index.
  4. Make sure that views are not used much and table is directly used in queries.
  5. Take backup of system and attempt to restore it to make sure it can be done easily in time of emergency.

Reference : Pinal Dave (http://blog.SQLAuthority.com)

About these ads

3 thoughts on “SQLAuthority News – Happy New Year – 5 SQL New Year Resolutions

  1. #4 – Make sure views are not used much and table is directly used in queries.

    We are currently going through a process of using views. This resolution leads me to believe that this is not a sound decision.

    Can you elaborate on this point please?
    Thanks,
    Kelley

  2. Pingback: SQL SERVER - Top Five Articles of Year 2008 Journey to SQL Authority with Pinal Dave

  3. What is this better

    Use JOIN syntax instead of using comma separate tables in FROM clause.
    Correct Syntax :
    SELECT *
    FROM TableName T
    INNER JOIN TableName2 T2 ON T.Col = T2.Col
    Incorrect Syntax : SELECT * FROM TableName T, TableName2 T2 WHERE T.Col = T2.Col

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s