Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SP won't compile w/ "Incorrect syntax near the keyword ORDER" error 1

Status
Not open for further replies.

dddenney

Programmer
Nov 29, 2000
41
US
I have the following SP I am trying to create...

create Proc procDirectoryFilter

(
@Filter nvarchar(1)
)
AS
(
SELECT *
FROM Users
WHERE SUBSTRING(LOWER(LName), 1, 1)=@Filter
ORDER BY LName
)

Everytime I try to compile it in Query Analyzer, it gives me the following error: "Incorrect syntax near the keyword ORDER". If I run the query by itself, it runs with no errors.

Any ideas?

Thanks in advance.

 
Your procedure is incorrect. The parenthesis don't belong in the script.

Code:
create Proc procDirectoryFilter
  @Filter nvarchar(1)
AS

 SELECT *
 FROM Users 
 WHERE SUBSTRING(LOWER(LName), 1, 1)=@Filter
 ORDER BY LName

See if that works. Refer to the BOL for CREATE PROCEDURE.

-SQLBill

BOL=Books OnLine=Microsoft SQL Server's HELP
Installed as part of the Client Tools
Found at Start>Programs>Microsoft SQL Server>Books OnLine

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top