Cast in Varchar with different options

  • I thought it was 20 characters and not 30 inside CAST/CONVERT.

    Thanks for the straightforward and back-to-basics question.

    Best regards,

    Andre Guerreiro Neto

    Database Analyst
    http://www.softplan.com.br
    MCITPx1/MCTSx2/MCSE/MCSA

  • An oldie but a goodie. Thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Toreador (7/16/2012)


    I was expecting to see a 100% correct rate given that the same thing has appear a lot in QOTDs over the last few months - but currently just 60% so obviously bears repeating.

    The moral as always is never to rely on default precision but always specify 🙂

    I have to admit I did not know the default was 30. Seems a bit arbitrary.

    I never cast or convert to varchar without specifying the width, but it would certainly help to know that in debugging someone else's code so thanks for the lesson.

  • davoscollective (7/17/2012)


    Toreador (7/16/2012)


    I was expecting to see a 100% correct rate given that the same thing has appear a lot in QOTDs over the last few months - but currently just 60% so obviously bears repeating.

    The moral as always is never to rely on default precision but always specify 🙂

    I have to admit I did not know the default was 30. Seems a bit arbitrary.

    I never cast or convert to varchar without specifying the width, but it would certainly help to know that in debugging someone else's code so thanks for the lesson.

    +1 (I have no memory, counting on the computer for memorizing stuff... but forget to check on the computer :hehe: )

    Funny that the default in designing is 50 for the varchar, but casting it is 30!

    Must be an engeneering logic: "Why make things simple when it is so simple to complicate it" :w00t:

    Thanks!

  • tilew-948340 (7/20/2012)


    davoscollective (7/17/2012)


    Toreador (7/16/2012)


    I was expecting to see a 100% correct rate given that the same thing has appear a lot in QOTDs over the last few months - but currently just 60% so obviously bears repeating.

    The moral as always is never to rely on default precision but always specify 🙂

    I have to admit I did not know the default was 30. Seems a bit arbitrary.

    I never cast or convert to varchar without specifying the width, but it would certainly help to know that in debugging someone else's code so thanks for the lesson.

    +1 (I have no memory, counting on the computer for memorizing stuff... but forget to check on the computer :hehe: )

    Funny that the default in designing is 50 for the varchar, but casting it is 30!

    Must be an engeneering logic: "Why make things simple when it is so simple to complicate it" :w00t:

    Thanks!

    + another 1.

    Tom

  • codebyo (7/17/2012)


    I thought it was 20 characters and not 30 inside CAST/CONVERT.

    Thanks for the straightforward and back-to-basics question.

    I thought it was 50 characters. If the B alternative was 49 characters I'd wrong.

    This is important in the case of development.

    Thanks

  • Good question, tested my knowledge of basic concepts.

  • ditto... did not know that 30 was the default.

    Jamie

  • PFA

    Anju Renjith

  • mailtoanjue (9/7/2012)


    PFA

    Anju Renjith

    Varchar with no length defaults to 30, as in query B.

    "El" Jerry.

    "A watt of Ottawa" - Gerardo Galvan

    To better understand your help request, please follow these best practices.[/url]

  • Basic quesion n easy to answer..+1:-D

  • Jamie Longstreet-481950 (8/25/2012)


    ditto... did not know that 30 was the default.

    +1...

    Regards,

    Manik

    Manik
    You cannot get to the top by sitting on your bottom.

  • OPPs ..

    but learn something

    Neeraj Prasad Sharma
    Sql Server Tutorials

  • i got all option for que in sql server 2008

  • its working fine in SQL server 2012. so answr is ALL;-)

Viewing 15 posts - 31 through 44 (of 44 total)

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