SQL syntax

  • mohammadk-1135894

    Hall of Fame

    Points: 3680

    Comments posted to this topic are about the item SQL syntax

  • malleswarareddy_m

    SSCertifiable

    Points: 5847

    I did not understand this question.in question it shows that to select wrong sytax.but all resturns table data without any error.then i did not found the wrong answer.so i applied three answers.got my point.

    Malleswarareddy
    I.T.Analyst
    MCITP(70-451)

  • mohammadk-1135894

    Hall of Fame

    Points: 3680

    Question was "Which of these SQL statements is correct?". Since all the SQL statements are correct then you have to check all the three answers.

  • Henrico Bekker

    One Orange Chip

    Points: 27652

    The question was:

    "Which of these SQL statements is correct? Please guess error message for those stements which are wrong. (select all that apply)"

    So 1st you have to select all the statements that are correct, then guess the error statements?

    ?

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle

  • Jinesh-I

    SSC Enthusiast

    Points: 134

    I have been using

    select *from table_name in SSMS 2005, since 2 years & it works fine.

    Please try once.

    Jinesh.

  • mohammadk-1135894

    Hall of Fame

    Points: 3680

    Hi, It seems my question was little confusing. but I want to ask which of these SQL statement are right?

    So all of the SQL statements was right!!! so you are rightly using the sytatement "select *from table_name"

    Sorry for the confusion.

  • emginet-874462

    SSC Veteran

    Points: 217

    Hi All the querys are correct

  • sharath.chalamgari

    SSCertifiable

    Points: 5680

    all the query works without any error

    You could have provided the a 4th option which says that all works without any error.

    confusing :hehe:

  • Carlo Romagnano

    SSC-Insane

    Points: 21793

    ???????????????????????????????????

    😎

    Try this:

    select*from sysobjects order by 1desc

    No space in 1desc

  • Hugo Kornelis

    SSC Guru

    Points: 64645

    I agree with others that the second sentence of the question: "Please guess error message for those stements which are wrong. (select all that apply)" gave the impression that we had to check which answers would result in an error message.

    Otherwise an intrigueing question about an interesting bit of information that, I hope, nobody will ever use in practice. 🙂 I'm hoping to see more questions from you in the future.


    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/

  • J.Faehrmann

    SSC Eights!

    Points: 957

    SELECT*FROM[sysobjects]ORDER BY 1desc

    or even

    EXEC('SELECT*FROM[sysobjects]ORDERBY1desc')

    welcome to SQL golfing - omg LOL

    The second thing is especialy bad, play with the order by to see why 😀

  • Ronald H

    SSCarpal Tunnel

    Points: 4022

    Carlo Romagnano (5/28/2010)


    Try this:

    select*from sysobjects order by 1desc

    No space in 1desc

    I've seen that too before, same like this:

    declare @a int set @a=1select @a

    However, select1 or select@a won't work. It seems that a keyword preceded by an integer always works. I would definitely avoid using it though, it only confuses me.

    Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/-------------------------------------------------------------------------2+2=5 for significant large values of 2

  • Carlo Romagnano

    SSC-Insane

    Points: 21793

    EXEC('SELECT*FROM[sysobjects]ORDERBY1desc')

    In this case the "order by" clause is missing

    ORDERBY1desc is the alias of [sysobjects]

  • ziangij

    SSCertifiable

    Points: 6958

    I've seen that too before, same like this:

    declare @a int set @a=1select @a

    However, select1 or select@a won't work. It seems that a keyword preceded by an integer always works. I would definitely avoid using it though, it only confuses me.

    agreed, it just increases confusion.

    However was wondering, when SSMS executes the query, it would have to do some effort to remove spaces between the words 🙂

  • vk-kirov

    SSCertifiable

    Points: 7686

    ziangij (5/28/2010)


    However was wondering, when SSMS executes the query, it would have to do some effort to remove spaces between the words 🙂

    SSMS itself does not execute queries because it is a client application. SSMS divides input text into batches, sequentially sends those batches to SQL Server, and displays received results. No spaces are added or removed while sending batches to the server. You can use SQL Server Profiler to see it.

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

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