• Jeff Moden (12/15/2010)


    nigel. (12/15/2010)


    Nice little eye opener Jeff, thanks.

    I particularly like :

    ...formatting data in SQL Server is your basic "Bozo-no-no"

    Can I quote that the next time I see another question like:

    "How do I get TSQL to format my datetime column to show just the date/time/whatever ...?" 🙂

    Absolutely but don't say "never" in the process because "It Depends". It's usually a horrible idea to burn clock cycles formatting in SQL Server for way too many reasons to list here (including local display settings in a global environment) but there IS the occasional justifiable need... sometimes there is no GUI to do the formatting for you especially if you're writing directly to a file.

    Some shops make extensive use of SQL Server agent jobs to output files directly (as unreliable as agent job failure detection and reporting is, it's still better than Windows Scheduler); and RTRIM() formatting saves considerable network traffic when your database was built by a vendor who didn't understand that VARCHAR() existed. Also, some languages don't really have formatting (most interactive voice response/telephony systems are an oddity in many ways).

    Formatting in SQL also has advantages in that multiple platforms and languages and programs receive consistent formatting.