ISNUMERIC

  • PRAMANA.DBA

    SSCertifiable

    Points: 5507

    Comments posted to this topic are about the item ISNUMERIC

  • happycat59

    One Orange Chip

    Points: 29189

    Mmm, why have "ISNUMERIC" as the heading for this question ? This question is not really about the ISNUMERIC function. How about getting the heading to match what the question is really about instead of deliberately trying to mislead ?

    This question is about the default length used for the VARCHAR data type. I am expecting a variation on this question to pop up soon where the answer is VARCHAR (30).

  • Lokesh Vij

    SSChampion

    Points: 10836

    happycat59 (3/5/2013)


    Mmm, why have "ISNUMERIC" as the heading for this question ? This question is not really about the ISNUMERIC function. How about getting the heading to match what the question is really about instead of deliberately trying to mislead ?

    This question is about the default length used for the VARCHAR data type. I am expecting a variation on this question to pop up soon where the answer is VARCHAR (30).

    +1 πŸ™‚

    Well this question is about ISNUMERIC and VARCHAR both. I realized the VARCHAR gotcha and marked the correct answer.

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • demonfox

    SSCertifiable

    Points: 6289

    Lokesh Vij (3/5/2013)


    happycat59 (3/5/2013)


    Mmm, why have "ISNUMERIC" as the heading for this question ? This question is not really about the ISNUMERIC function. How about getting the heading to match what the question is really about instead of deliberately trying to mislead ?

    This question is about the default length used for the VARCHAR data type. I am expecting a variation on this question to pop up soon where the answer is VARCHAR (30).

    +1 πŸ™‚

    Well this question is about ISNUMERIC and VARCHAR both. I realized the VARCHAR gotcha and marked the correct answer.

    well, in a way it is true .. varchar does store only "3"; the first character ..

    and ISNumeric does evaluate the string "3" as numeric .. I look at heading to get extra information , but, here straightforward question ..

    nice and simple ...

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • Vinay Kumar

    SSCertifiable

    Points: 6098

    demonfox (3/5/2013)


    Lokesh Vij (3/5/2013)


    happycat59 (3/5/2013)


    Mmm, why have "ISNUMERIC" as the heading for this question ? This question is not really about the ISNUMERIC function. How about getting the heading to match what the question is really about instead of deliberately trying to mislead ?

    This question is about the default length used for the VARCHAR data type. I am expecting a variation on this question to pop up soon where the answer is VARCHAR (30).

    +1 πŸ™‚

    Well this question is about ISNUMERIC and VARCHAR both. I realized the VARCHAR gotcha and marked the correct answer.

    well, in a way it is true .. varchar does store only "3"; the first character ..

    and ISNumeric does evaluate the string "3" as numeric .. I look at heading to get extra information , but, here straightforward question ..

    nice and simple ...

    +1

    Good start of day. πŸ™‚

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!

  • kapil_kk

    SSC-Insane

    Points: 21316

    good basic question to start the day....

    In first line I saw that its only varchar to length would be 1 only and 3 is present in text so quickly mark the answer as IS Numeric πŸ˜›

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • demonfox

    SSCertifiable

    Points: 6289

    happycat59 (3/5/2013)


    Mmm, why have "ISNUMERIC" as the heading for this question ? This question is not really about the ISNUMERIC function. How about getting the heading to match what the question is really about instead of deliberately trying to mislead ?

    a litle modification in the question and a missing reference .. and it would go for the header πŸ˜€

    DECLARE @vchrIsNumeric CHAR(2)

    SET @vchrIsNumeric='3 NAME'

    IF ISNUMERIC(@vchrIsNumeric)=1

    SELECT 'Is Numeric'

    ELSE

    SELECT 'Is not Numeric'

    output would be the same ..(might put a dot for a second :-P)

    and here is the missing reference on IS_Numeric :

    http://msdn.microsoft.com/en-gb/library/ms186272.aspx

    Edit :

    This question is about the default length used for the VARCHAR data type. I am expecting a variation on this question to pop up soon where the answer is VARCHAR (30).

    yes.. It might :hehe:

    as mentioned in msdn :

    When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified when using the CAST and CONVERT functions, the default length is 30.

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • Raghavendra Mudugal

    SSChampion

    Points: 10658

    well....i did it again......

    knowing the declaration without the size will default to 1 and at the time of cast/convert it defaults to 30.... and... me being dumbest of all the time i mentally switched the answers and considered 30 as the default to the variable with no size... thinking "is not numeric" is a straight and sweet deal...

    ...

    ..

    .

    (one second later) after clicking the submit the button

    .

    .

    #facepalm

    (sorry) good question by the way; thank you for posting, remembrance of the defaults is another key point in the level of basic. thank you.

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • Dineshbabu

    Hall of Fame

    Points: 3220

    I read the question very carelessly. I didn't notice that variable declared without specifying length.

    --
    Dineshbabu
    Desire to learn new things..

  • DugyC

    Hall of Fame

    Points: 3804

    Don't really pay attention to the heading as it can often be misleading and just focus entirely on the detail of the question.

    I like these "gotcha" bug style questions, little reminders of what's waiting in SQL to catch the unwary LOL!

    Good nice question with a quick answer. Great job.

    Thanks πŸ˜€

    _____________________________________________________________________
    [font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]

  • db4breakfast

    Ten Centuries

    Points: 1097

    haha. this not really about IsNumeric(). these type of questions are fun to solve. πŸ˜€

    --------------------------------------------------------------------------------------
    Hai Ton
    My Db4Breakfast blog.

  • amit_adarsh

    Ten Centuries

    Points: 1273

    Nice question to check the attentiveness

    as well as to expalin the default behaviour of Varchar data type 😎

  • This was removed by the editor as SPAM

  • TomThomson

    SSC Guru

    Points: 104772

    Nice question, but I don't much like the heading. Fortunately I've learnt not to pay much attention to QotD headings.

    Tom

  • Hugo Kornelis

    SSC Guru

    Points: 64675

    L' Eomot InversΓ© (3/6/2013)


    Nice question, but I don't much like the heading. Fortunately I've learnt not to pay much attention to QotD headings.

    I never look at the headings either, so this didn't bother me.

    And while I understand the objections raised, I also think that this adds a nice touch of realism. If a junior on my team made this mistake and came to me after not beiing able to figure it out, they would probably also tell me that they have a problem with ISNUMERIC.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

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

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