Intresting Question need answer ASAP

  • Write the shortest code that produces results as 1 without using any numbers in the select statement. using sql

  • One more

    SELECT CAST(634 AS VARCHAR(2))

    why it display * in result

  • PRINT 1

    Doesn't use a SELECT statement 😉

    Homework?

    Andy

    ==========================================================================================================================
    A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe

  • SELECT LEN('a')

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (9/20/2012)


    SELECT LEN('a')

    ha, thats what i came up with 😀

  • One more

    SELECT CAST(634 AS VARCHAR(2))

    why it display * in result

    Someone else also asked this

    http://www.sqlservercentral.com/Forums/Topic1361763-149-1.aspx

    ==========================================================================================================================
    A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe

  • vax09 (9/20/2012)


    One more

    SELECT CAST(634 AS VARCHAR(2))

    why it display * in result

    Overflow, you are trying to convert the number 634 to a string but only giving the string 2 characters of space where 3 are needed.

  • For this query

    SELECT CAST(634 AS VARCHAR(2))

    why it display * in result

  • Andy Hyslop (9/20/2012)


    Someone else also asked this

    http://www.sqlservercentral.com/Forums/Topic1361763-149-1.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • vax09 (9/20/2012)


    For this query

    SELECT CAST(634 AS VARCHAR(2))

    why it display * in result

    String truncation.

    - 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

  • Now, now, Gentlemen. :rolleyes:

    The questions posted here are from today's blog by Pinal Dave on SQLAuthority. You can ask any question, but perhaps some of us would like to compete as well. (Dave is offering a $50 Amazon.com gift card to the winner.)

    For those interested, you can enter the competition here: http://blog.sqlauthority.com/

  • Okay, these people should be disqualified.

  • Somehow I think SELECT LEN('a') is too simple for Dave's competition. There must be some really obscure way of returning a 1.

    I'm wracking my brain trying to think of what it might be. :unsure:

  • David Moutray (9/20/2012)


    Somehow I think SELECT LEN('a') is too simple for Dave's competition. There must be some really obscure way of returning a 1.

    I'm wracking my brain trying to think of what it might be. :unsure:

    Why would you think that this would be too simple?

  • This isn't that short, but at least it's obscure. :ermm:

    select power('','')

    Results:

    ----------------------

    1

    (1 row(s) affected)

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

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