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 (https://blog.sqlauthority.com)

Best Practices, SQL Scripts
Previous Post
SQLAuthority News – Recap Year 2008 – Two Most Important Event of My Life
Next Post
SQL SERVER – 2008 – 2005 – Find Longest Running Query – TSQL

Related Posts

2 Comments. Leave new

  • #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

    Reply
  • 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

    Reply

Leave a Reply