SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL syntax


SQL syntax

Author
Message
J.Faehrmann
J.Faehrmann
Mr or Mrs. 500
Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)

Group: General Forum Members
Points: 536 Visits: 1442

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 :-D
Ronald H
Ronald H
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1270 Visits: 620
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 Hensbergen

Help 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
Carlo Romagnano
SSCertifiable
SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)

Group: General Forum Members
Points: 5029 Visits: 3327
[quote]

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


In this case the "order by" clause is missing
ORDERBY1desc is the alias of [sysobjects]

I run on tuttopodismo
ziangij
ziangij
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3138 Visits: 376
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
vk-kirov
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3728 Visits: 4408
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.
Daniel Bowlin
Daniel Bowlin
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4136 Visits: 2629
They may all work, but they are all a crime against readability. I make a point of white space for readability just about everywhere.
Mike Dougherty
Mike Dougherty
SSC-Enthusiastic
SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)

Group: General Forum Members
Points: 184 Visits: 952
"A crime against readability" I'll reuse that quote soon enough.
Tom Garth
Tom Garth
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1263 Visits: 1499
I'm afraid I have to join the chorus in saying the question was poorly worded.

Interesting info though.

Tom Garth
Vertical Solutions

"There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers

ken.trock
ken.trock
SSChasing Mays
SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)

Group: General Forum Members
Points: 649 Visits: 1730
malleswarareddy_m (5/27/2010)
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.


He did say "select all that apply"

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


The part about guessing the error messages, if there are any, are for extra credit:-D

Ken
ahrar.mustafa
ahrar.mustafa
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 28
All are correct
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search