SQL syntax

  • Comments posted to this topic are about the item SQL syntax

  • 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)

  • 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.

  • 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

  • I have been using

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

    Please try once.

    Jinesh.

  • 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.

  • Hi All the querys are correct

  • 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:

  • ???????????????????????????????????

    😎

    Try this:

    select*from sysobjects order by 1desc

    No space in 1desc

  • 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/

  • 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 😀

  • 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

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

    In this case the "order by" clause is missing

    ORDERBY1desc is the alias of [sysobjects]

  • 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 🙂

  • 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 37 total)

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