Strange T-SQL Behavior

  • Good to know. Thanks for trying it out.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • ...You could really mess with people's heads with this.

    Well it obviously did with yours 😛

    Far away is close at hand in the images of elsewhere.
    Anon.

  • David Burrows (5/26/2009)


    ...You could really mess with people's heads with this.

    Well it obviously did with yours 😛

    Yeah, but I'm a head case on the best days. I'm talking about normal people.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • ...I'm talking about normal people.

    I thought it was a prerequisite that normal people were not allowed on this forum :crazy: :w00t:

    Far away is close at hand in the images of elsewhere.
    Anon.

  • SQL Server takes the numeric value up to the first Alpha character as a numeric value (SELECT 1.) and the alpha characters that follow are then the alias for the column.

    Except for SELECT 1.eColumnName

    Far away is close at hand in the images of elsewhere.
    Anon.

  • David Burrows (5/26/2009)


    SQL Server takes the numeric value up to the first Alpha character as a numeric value (SELECT 1.) and the alpha characters that follow are then the alias for the column.

    Except for SELECT 1.eColumnName

    Works for me. Returns a single row value of 1 with a column header of ColumnName.

  • I've actually seen this before. Don't remember where, but we came to the same conclusion that it's a whitespace parsing thing.

    Would make a good QotD submission, Grant.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • GSquared (5/26/2009)


    I've actually seen this before. Don't remember where, but we came to the same conclusion that it's a whitespace parsing thing.

    Would make a good QotD submission, Grant.

    I submitted one last week. Look for it in September.

  • john.arnott (5/26/2009)


    GSquared (5/26/2009)


    I've actually seen this before. Don't remember where, but we came to the same conclusion that it's a whitespace parsing thing.

    Would make a good QotD submission, Grant.

    I submitted one last week. Look for it in September.

    Cool biz.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Lynn Pettis (5/26/2009)


    David Burrows (5/26/2009)


    SQL Server takes the numeric value up to the first Alpha character as a numeric value (SELECT 1.) and the alpha characters that follow are then the alias for the column.

    Except for SELECT 1.eColumnName

    Works for me. Returns a single row value of 1 with a column header of ColumnName.

    What I was referring to was SQL Server takes the numeric value up to the first Alpha character

    SELECT 1.eColumnName

    returns

    ColumnName

    1.0

    My bad for not highlighting the right bit :blush:

    Far away is close at hand in the images of elsewhere.
    Anon.

  • I've just tried this on a SQL 6.5 DB and it produces the same result so this must go way back! How cool! 😀

  • I also noticed that the SSMS correctly colorizes it too.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Try:

    SELECT

    30.AString

    ,50.E-3AnotherString

    ,10.E0SomethingElse

    into dbo.TempTable;

    select * from dbo.TempTable;

    You can see that SQL try to parse the number till the not numeric character and then take the rest as alias to the column.

    Izhar Azati

  • izhar (5/29/2009)


    Try:

    SELECT

    30.AString

    ,50.E-3AnotherString

    ,10.E0SomethingElse

    into dbo.TempTable;

    select * from dbo.TempTable;

    You can see that SQL try to parse the number till the not numeric character and then take the rest as alias to the column.

    Izhar Azati

    Same results also in SQL Server 2005!

    Many things is going to be happened that we didn't know before ...:hehe:

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

Viewing 14 posts - 31 through 43 (of 43 total)

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