Home > incorrect syntax > incorrect syntax near the keyword desc sql error

Incorrect Syntax Near The Keyword Desc Sql Error

Contents

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business desc command in sql server Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation

Incorrect Syntax Near The Keyword Order

Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Incorrect syntax near the keyword 'DESC' up vote 0 down vote favorite I'm trying to write an SQL query but when I try to save it throws me an incorrect syntax error. Here's the query: ( @top int, @bottom int ) AS SELECT * FROM (SELECT top (@bottom - @top + 1) * FROM (SELECT top (@bottom) * FROM tblPlayers INNER JOIN tblPosition ON tblPlayers.IDPosition = tblPosition.IDPosition INNER JOIN tblTeams ON tblPlayers.IDTeam = tblTeams.IDTeam ORDER BY (PPG DESC, APG DESC, RPG DESC) ) ORDER BY PPG ASC, APG ASC, RPG ASC ) ORDER BY PPG DESC, APG DESC, RPG DESC RETURN The problem is with the most inner ORDER BY. Without it's brackets it gives an incorrect syntax near the keyword 'ORDER'. With the brackets the error is incorrect syntax near the keyword 'DESC'. I'm out of ideas. The syntax seems fine to me. Thanks in advance. sql sql-server sql-order-by share|improve this question edited May 18 '14 at 13:34 Gordon Linoff 468k20140213 asked May 18 '14 at 13:30 iMax531 4211 PLease tell us what concrete database you're using - use the oracle, mysql, postgresql, sql-server tags - or specify what else you're using (SQL is just the query language - not a product). ALso - this is not a complete code snippet - is this the body of a stored procedure? Of a CTE? Please post something complete - not just a few lines out of the middle of something.... –marc_s May 18 '14 at 13:32 I added the sql-server tag because the syntax looks like SQL Server. –Gordon Linoff May 18 '14 at 13:34 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted Your query needs table aliases, which may be part or all of the problem. In addition, you should list the columns explicitly in the innermost subquery, because there are duplicate names: SELECT t.* FROM (SELECT top (@bo

ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Getting Started/Incorrect syntax near the keyword 'DESC'. Incorrect syntax near the keyword 'DESC'. [Answered]RSS 7 replies Last post May 12, 2012 07:48 AM by sunitashirsat ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Reply sriramabi Contributor 2428 Points 1124 Posts Incorrect syntax near the keyword 'DESC'. May 12, 2012 06:58 AM|sriramabi|LINK i have one select query .but its showing threw error:Msg 156, Level 15, State http://stackoverflow.com/questions/23722447/incorrect-syntax-near-the-keyword-desc 1, Line 1 Incorrect syntax near the keyword 'DESC'. my query is select Top10 from Jp_JobPosting Group By AddedDate DESC what problem pls help me Reply ignatandrei All-Star 119052 Points 27460 Posts ModeratorMVP Re: Incorrect syntax near the keyword 'DESC'. May 12, 2012 07:00 AM|ignatandrei|LINK order by .NET Teacher | .NET Videos 5 minutes Reply sriramabi Contributor 2428 Points 1124 Posts http://forums.asp.net/t/1803030.aspx?+Incorrect+syntax+near+the+keyword+DESC+ Re: Incorrect syntax near the keyword 'DESC'. May 12, 2012 07:01 AM|sriramabi|LINK S i m sorry.. select Top(10) * from Jp_JobPosting order By AddedDate DESC its working well.. thank u Reply THINESH Member 98 Points 120 Posts Re: Incorrect syntax near the keyword 'DESC'. May 12, 2012 07:04 AM|THINESH|LINK SELECT TOP 10 NAME FROM EMPLOYEE_DETAILS ORDER BY SALARY DESC; OR SELECT TOP 3 PERSON FROM EVENTMASTER ORDER BY DATE DESC THIS ILL WORK T T Reply sriramabi Contributor 2428 Points 1124 Posts Re: Incorrect syntax near the keyword 'DESC'. May 12, 2012 07:09 AM|sriramabi|LINK THINESH SELECT TOP 10 NAME FROM EMPLOYEE_DETAILS ORDER BY SALARY DESC; THIS ILL WORK Hai THINESH andignatandrei ..You want mark us answer..bcas i m owner of asp.net forums........................this thread..... tack it yha its my misstack ..so i m sry... select Top(10) * from Jp_JobPosting order By AddedDate DESC its working.... Reply sunitashirsa... Member 113 Points 303 Posts Re: Incorrect syntax near the keyword 'DESC'. May 12, 2012 07:10 AM|sunitashirsat|LINK It should beselect Top10 from Jp_JobPosting order By AddedDate DESC Sunita R Shirsat Reply sriramabi Con

(2) June, 2010 (1) December, 2009 (1) November, 2009 (2) April, 2008 (1) July, 2007 (1) March, 2007 (2) February, 2007 (4) December, 2006 (1) November, 2006 (2) September, 2006 (4) August, 2006 (2) July, 2006 (2) June, 2006 (3) May, http://weblogs.sqlteam.com/BRETTK/archive/2005/04/25/4679.aspx 2006 (2) November, 2005 (1) October, 2005 (1) September, 2005 (1) August, 2005 (2) June, 2005 (8) May, 2005 (6) April, 2005 (5) February, 2005 (4) January, 2005 (5) December, 2004 (2) October, 2004 (2) September, 2004 (2) August, 2004 (1) June, 2004 (6) May, 2004 (2) April, 2004 (2) March, 2004 (2) February, 2004 (3) January, 2004 (2) October, 2003 (1) September, 2003 (1) Post Categories SQL Server (rss) DB2 (rss) Disconnected Ramblings (rss) Oracle (rss) Code Generataion incorrect syntax (rss) SQL Gimmicks (rss) Image Galleries Lost Again? SQLSki Team Misc Mountains Directions Misc It's an Enigma Wrapped up in a riddle Little Feat (rss) Radio 'Rita Ski Resort Cam List SQL Server Daily WTF (Doesn't mean World Tennis Federation) dbForums Member List SQL Express Team's BLOG SQL Server 2000 Books Online SQLTeam SQLTeam Member List << CREATE TYPE2 UNIQUE WHERE NULL INDEX | Home | TRUNCATE TABLE in DB2 >> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax incorrect syntax near near the keyword 'DESC'. bcp fails to import data near reserved word. [Doooh]Alrighty then. Thanks Tara (again) for pointing out the obvious. The resolution to this problem is the -q option. As BOL states, it sets quoted identifiers on in the context of the bcp thread. So that solves that problem, and I'm sure it's one that I won't forget. It's curious why there isn't a problem with the bcp out though.[/Doooh] BOL -q Executes the SET QUOTED_IDENTIFIERS ON statement in the connection between the bcp utility and an instance of SQL Server. Use this option to specify a database, owner, table, or view name that contains a space or a quotation mark. Enclose the entire three-part table or view name in double quotation marks (" "). Who knew? OK, probably everyone. I have never run into this before (mostly because I don't use reserve words as column names). The work around I used was to create a view. If anyone has a slicker way, or better, an explanation as to why bcp does fail, I'm all ears...or is that eyes? In any case....something for future reference so I don't have to remember it, and hopefully someone else might benefit. USE NorthwindGO SET NOCOUNT ONCREATE TABLE myTable99(Col1 int, [DESC] varchar(8000))GO INSERT INTO myTable99 (Col1, [DESC])SELECT 1, 'I' UNION ALLSELECT 2, 'Me' UNION ALLSELECT 3, 'Mine'GO SELECT * FROM myTable99 EXEC master..xp_cmdshell 'bcp Northwind.dbo.myTable99 out d:\data

 

Related content

ado net syntax error near

Ado Net Syntax Error Near table id toc tbody tr td div id toctitle Contents div ul li a href Cmd executenonquery Error In C a li li a href Cmd executenonquery Error Vb a li li a href Cmd executenonquery In C a li li a href Additional Information Incorrect Syntax Near a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any relatedl questions you might have Meta Discuss the workings p h id Cmd executenonquery Error In C p and policies of this site About Us

cross apply error incorrect syntax near

Cross Apply Error Incorrect Syntax Near table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near go a li li a href Incorrect Syntax Near The Keyword with a li li a href Incorrect Syntax Near The Keyword select a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss relatedl the workings and policies of this site About Us Learn sql server cross apply incorrect syntax near more about Stack Overflow the company Business

error 1 incorrect syntax near external

Error Incorrect Syntax Near External table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near go a li li a href Incorrect Syntax Near The Keyword with a li li a href Incorrect Syntax Near The Keyword select a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the relatedl workings and policies of this site About Us Learn more incorrect syntax near begin expecting external about Stack Overflow the company Business Learn more

error 156 incorrect syntax near the keyword

Error Incorrect Syntax Near The Keyword table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near The Keyword identity a li li a href Incorrect Syntax Near The Keyword declare a li li a href Incorrect Syntax Near The Keyword set a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions relatedl you might have Meta Discuss the workings and policies incorrect syntax near the keyword case of this site About Us Learn more about Stack Overflow the company

error 156 incorrect syntax near the keyword case

Error Incorrect Syntax Near The Keyword Case table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near The Keyword group a li li a href Incorrect Syntax Near The Keyword select a li li a href Incorrect Syntax Near The Keyword identity a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more relatedl about Stack Overflow the company Business Learn more about hiring

how to raise error

How To Raise Error table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near Raiseerror a li li a href Sql Server Raiserror Stop Execution a li li a href Sql Throw Exception In Stored Procedure a li li a href Sp addmessage a li ul td tr tbody table p Microsoft Tech Companion App Microsoft Technical Communities Microsoft Virtual Academy Script Center relatedl Server and Tools Blogs TechNet Blogs TechNet p h id Incorrect Syntax Near Raiseerror p Flash Newsletter TechNet Gallery TechNet Library TechNet Magazine TechNet Subscriptions raiserror vs throw

how to throw error in sql stored procedure

How To Throw Error In Sql Stored Procedure table id toc tbody tr td div id toctitle Contents div ul li a href Sql Server Throw Vs Raiserror a li li a href Sql Server Raiserror Stop Execution a li li a href Incorrect Syntax Near Throw Expecting Conversation a li li a href Raiserror With Nowait a li ul td tr tbody table p resources Windows Server resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums relatedl Blogs Channel Documentation APIs and reference Dev centers Samples p h

incorrect syntax near microsoft sql server error 102

Incorrect Syntax Near Microsoft Sql Server Error table id toc tbody tr td div id toctitle Contents div ul li a href Error Code Sql State Incorrect Syntax Near a li li a href Sql Error Code a li li a href Sql State S Error Code a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta relatedl Discuss the workings and policies of this site About Us incorrect syntax near sqlstate error Learn more about Stack Overflow the company Business Learn more

incorrect syntax near error in sql

Incorrect Syntax Near Error In Sql table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near Sql Server a li li a href Incorrect Syntax Near On a li li a href Sql Incorrect Syntax Near Equal a li li a href Sql Incorrect Syntax Near The Keyword a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the relatedl

incorrect syntax near sqlstate 42000 error 102

Incorrect Syntax Near Sqlstate Error table id toc tbody tr td div id toctitle Contents div ul li a href Sql Error Incorrect Syntax Near a li li a href Sql State S Error Code a li li a href Sql Error Incorrect Syntax Near a li ul td tr tbody table p here for a quick overview of the site Help relatedl Center Detailed answers to any questions you might sql server error code have Meta Discuss the workings and policies of this site About p h id Sql Error Incorrect Syntax Near p Us Learn more about Stack

incorrect syntax error

Incorrect Syntax Error table id toc tbody tr td div id toctitle Contents div ul li a href Bash Syntax Error Near a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions relatedl you might have Meta Discuss the workings and policies incorrect syntax near sql server stored procedure of this site About Us Learn more about Stack Overflow the company Business syntax error near verilog Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges incorrect syntax near

incorrect syntax or error detected in the persistence.xml

Incorrect Syntax Or Error Detected In The Persistence xml p with a mandatory word e g keyword keyword keyword Questions excluding relatedl a word e g keyword keyword -keyword Questions with a specific tag and keyword s tag keyword Questions with two or more specific tags and keyword s tag tag keyword To search for all posts by a user or all posts with a specific tag start typing and choose from the suggestion list Tags Spaces API Connect Appsecdev BPM Blockchain Bluemix CICS Cloud Analytics Cloud marketplace Content Services ECM Continuous Testing Courses DB LUW DataPower Decision Optimization DevOps

incorrect syntax near error

Incorrect Syntax Near Error table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near In Sql Server a li li a href What Is Incorrect Syntax a li li a href Incorrect Syntax Near Comma a li li a href Sql Incorrect Syntax Near Equal a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this relatedl site About Us Learn more about Stack Overflow the company Business p

incorrect syntax near sql script error

Incorrect Syntax Near Sql Script Error table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near In Sql Server a li li a href Incorrect Syntax Near In Sql Server a li li a href Incorrect Syntax Near Visual Studio a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About relatedl Us Learn more about Stack Overflow the company Business Learn more incorrect syntax near sql

microsoft sql server error 102

Microsoft Sql Server Error table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near Sql Server a li li a href Incorrect Syntax Near Sql Server Stored Procedure a li li a href Msg Incorrect Syntax Near a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss relatedl the workings and policies of this site About Us incorrect syntax near sqlstate error Learn more about Stack Overflow the company Business Learn more about hiring

microsoft sqlserver error 102

Microsoft Sqlserver Error table id toc tbody tr td div id toctitle Contents div ul li a href Error Code Sql State Incorrect Syntax Near - a li li a href Incorrect Syntax Near In Sql Server a li li a href Sql Error Incorrect Syntax Near a li ul td tr tbody table p games PC games incorrect syntax near sqlstate error Windows games Windows phone games Entertainment All Entertainment incorrect syntax near sql server Movies TV Music Business Education Business Students educators p h id Error Code Sql State Incorrect Syntax Near - p Developers Sale Sale Find

ms sql error code 102

Ms Sql Error Code table id toc tbody tr td div id toctitle Contents div ul li a href Sql Error Incorrect Syntax Near a li li a href Sql State S Error Code a li li a href Incorrect Syntax Near Sql Server a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions relatedl you might have Meta Discuss the workings and policies incorrect syntax near sqlstate error of this site About Us Learn more about Stack Overflow the company Business p h id Sql Error

ms sql error number 102

Ms Sql Error Number table id toc tbody tr td div id toctitle Contents div ul li a href Sql Server Error Code a li li a href Error Code Sql State Incorrect Syntax Near a li li a href Sql State S Error Code a li li a href Msg Level State Line Incorrect Syntax Near a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might relatedl have Meta Discuss the workings and policies of this p h id Sql Server Error Code p

ms sql error 156

Ms Sql Error table id toc tbody tr td div id toctitle Contents div ul li a href Msg Level State Incorrect Syntax Near The Keyword Select a li li a href Sql Error a li li a href Incorrect Syntax Near The Keyword order a li ul td tr tbody table p here for a quick overview of the site Help relatedl Center Detailed answers to any questions you might incorrect syntax near the keyword union sql server have Meta Discuss the workings and policies of this site About p h id Msg Level State Incorrect Syntax Near The

ms sql server error code 102

Ms Sql Server Error Code table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near Sqlstate error a li li a href Sql Error Incorrect Syntax Near a li li a href Incorrect Syntax Near In Sql Server a li li a href Incorrect Syntax Near Sql Server a li ul td tr tbody table p Error exporting tables Oct Feature Request SQL Views data tab Oct format SQL- select statement Oct BUG relatedl - SQL Server column description not Oct p h id Incorrect Syntax Near Sqlstate error p Feature Request

mssql error code 102

Mssql Error Code table id toc tbody tr td div id toctitle Contents div ul li a href Sql Error Incorrect Syntax Near a li li a href Error Code Sql State Incorrect Syntax Near a li li a href Sql State S Error Code a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow relatedl the company Business Learn more about hiring developers or posting ads with

mssqlserver error number 102

Mssqlserver Error Number table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near Sql Server Stored Procedure a li li a href Incorrect Syntax Near In Sql Server a li ul td tr tbody table p Source MSSQLServer Error number errors relatedl in replication x x x x x x x x x x x x x x x Sakthivel ChidambaramOctober Share incorrect syntax near sql server A quick guide on how to troubleshoot Incorrect sql server error code syntax near - Source MSSQLServer Error number errors in replication Firstly check for

native error 102

Native Error table id toc tbody tr td div id toctitle Contents div ul li a href Sql State S Error Code a li li a href Sql Error Incorrect Syntax Near a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of relatedl this site About Us Learn more about Stack Overflow the company incorrect syntax near sqlstate error Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs sql server error

native error 156

Native Error table id toc tbody tr td div id toctitle Contents div ul li a href Msg Level State Sql Server a li li a href Sql Error Code a li li a href Msg Level State Line Incorrect Syntax Near The Keyword from a li li a href Incorrect Syntax Near The Keyword order a li ul td tr tbody table p WizardInformatica Cloud for Amazon AWSComplex Event ProcessingProactive Healthcare Decision ManagementProactive MonitoringReal-Time Alert ManagerRule relatedl PointData IntegrationB B Data ExchangeB B Data TransformationData incorrect syntax near the keyword union sql server Integration HubData ReplicationData ServicesData Validation OptionFast

odbc error incorrect syntax near

Odbc Error Incorrect Syntax Near table id toc tbody tr td div id toctitle Contents div ul li a href microsoft odbc Sql Server Driver sql Server incorrect Syntax Near a li li a href Incorrect Syntax Near In Sql Server a li ul td tr tbody table p sphere login blackbaud labs noza blackbaud tv netwits thinktank usa uk pacific netherlands canada ERROR Error fetching records relatedl DoSearch General ODBC Error Microsoft ODBC SQL Server Driver SQL Server Incorrect p h id microsoft odbc Sql Server Driver sql Server incorrect Syntax Near p syntax near the keyword AS Native

raise error tsql

Raise Error Tsql table id toc tbody tr td div id toctitle Contents div ul li a href Incorrect Syntax Near Throw a li li a href Sp addmessage a li li a href Invalid Use Of A Side-effecting Operator raiserror Within A Function a li ul td tr tbody table p Microsoft Tech Companion App Microsoft Technical Communities Microsoft Virtual Academy Script Center Server and relatedl Tools Blogs TechNet Blogs TechNet Flash Newsletter raiserror vs throw TechNet Gallery TechNet Library TechNet Magazine TechNet Subscriptions TechNet Video incorrect syntax near raiseerror TechNet Wiki Windows Sysinternals Virtual Labs Solutions Networking Cloud