Integer lengths (I)

  • Comments posted to this topic are about the item Integer lengths (I)

    Tom

  • Surely this question is less about integer lengths and more about string conversions?

    What it's really drawing attention to is that str(), which produces a fixed length string, left pads on conversion, while cast/convert right pad a fixed length string. This happens regardless of whether the input is an integer.

    Good question though - certainly highlighted something I was unaware of - glad I always opt for explicit type conversions 🙂

  • Great question, thanks!

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

  • Nice,failed due to the right justified result of STR.

  • Well done, Tom. Not only way it clear, concise and correct, it made me think it through, which is always good. Thanks.

  • Nice question, thanks Tom.

    ---------------------------------------------------
    "Thare are only 10 types of people in the world:
    Those who understand binary, and those who don't."

  • Nice question Tom. I haven't used the STR() function before.

  • Good one. Learned something by getting it wrong. 🙂

  • Stewart "Arturius" Campbell (6/30/2015)


    Nice question, thanks Tom

    Never been fond of the STR() function myself, as i prefer explicit cast/convert

    +1. My thoughts exactly.

  • Cool question, thanks.

    - webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • Very neat. Thanks you, Tom!

  • great question. thanks for sharing

  • Is NULL=NULL true ?

    That's the question.

    Most things in life can be reduced to one single question.

  • Stewart "Arturius" Campbell (7/1/2015)


    ArnoKwetters (7/1/2015)


    Is NULL=NULL true ?

    NULL != NULL or anything else.

    NULL is actually a reflection of the state of the field, i.e. there is no value assigned to it.

    This is where playing aound with SET ANSI_NULL delivers some interesting results...

    Thank u!

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Stewart "Arturius" Campbell (7/1/2015)


    ArnoKwetters (7/1/2015)


    Is NULL=NULL true ?

    NULL != NULL or anything else.

    NULL is actually a reflection of the state of the field, i.e. there is no value assigned to it.

    This is where playing aound with SET ANSI_NULL delivers some interesting results...

    [/quote

    Yes, my question and answer assume ANSI_NULL is set on; that is the default situation for sQL Server, and the ability to set it off has been deprecate for a very long time and will soon be unavailable. Any comparison involving NULL (either as both arguments or as one f them) delivers UNKNOWN - not TRUE, and not FALSE.

    Tom

Viewing 15 posts - 1 through 15 (of 19 total)

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