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
Server Message: Number 156, Severity 15 Incorrect syntax near the keyword 'Select'. Server Message: Number 102, Severity 15 Incorrect syntax near ')'.
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.
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?
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.