How to get YYYYMMDDHHMMSS

  • MMartin1 wrote:

    Data type disparity on join conditions etc is not really an after thought I've seen over time, its more like a 'no thought.' You bring up an excellent point that a simple adjustment here should be done to pass code review.

    And just a fun fact regarding char/varchar, from Microsoft docs, > "When n isn't specified in a data definition or variable declaration statement, the default length is 1. If n isn't specified when using the CAST and CONVERT functions, the default length is 30."

    I think the reason the default length is 30 inside CAST/CONVERT is so you don't have to specify a length when doing most conversions. e.g.:

    SELECT CONVERT(varchar, GETDATE(),121)

    Will successfully convert a date into a character string.

     

Viewing post 16 (of 15 total)

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