Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Sysntax Error.

 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Can anyone please help me out below is the stored procedure and error.
I am using Sybase BUT when i run this on SQL Server 2000 it works fine no error. But on Sybase it is throwing an error please help me out.
This is second time i ve posted this.

============================================
Create Procedure spGetMaximumVersionForid
@id int
As

Select id,Version = IsNull(Max(Ver),0)
From
(
Select id,Ver = Max(Version)
From ModifiedForm
Group By id
Union
Select id,Ver = Max(Version)
From ReqForm
Group By id
) As DT
Where id= @id
Group By id

GO
=================================

Server Message: Number 156, Severity 15
Incorrect syntax near the keyword 'Select'.
Server Message: Number 102, Severity 15
Incorrect syntax near ')'.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ghazanfar,
It's likely nobody answered because they didn't know. It certainly looks right to me.

Try a standard troubleshooting trick to narrow down the problem: see how much of the stored proc you can remove and still get the compiler error. Often doing this helps see it better. Once you do that, you may see it yourself. If not, post the simplified stored proc in this thread.
 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne , it is fine on SQL Server but NOT when i run it on Sybase. anyway thanks.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Khan,
I don't have an answer for you, and please forgive me if this is a silly question, but I don't know Sybase nor SQL Server and I am curious.

For your procedure to work in both databases, both databases would need to have identical syntax. Are you sure that they do?

In my experience with Oracle and Informix databases, the syntax used for writing stored procedures in those two databases is totally different. There is no way I could run an Oracle stored procedure in an Informix database -- and vice-versa.

The error message you are getting seems to indicate that Sybase and SQL Server do, indeed, use different syntax for defining stored procedures. So I repeat, why do you think the exact same procedure definition should work in both Sybase and SQL Server?

Good Luck,
Avi.
 
vernon mweetwa
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Khan,

I totally agree with Avi on what he is saying, meaning the syntax of using certain key words like SELECT maybe different because of different vendors. Try to check on a simplified way of how Sybase uses the SELECT word and from there you will find the solution. It is rare to find the same SQL script running the same way on different databases without making a few changes to form to the new type of database.
 
ghazanfar khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks all of you for giving me a good suggestion..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic