• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

SQL Sysntax Error.

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ')'.
 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne , it is fine on SQL Server but NOT when i run it on Sybase. anyway thanks.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks all of you for giving me a good suggestion..
 
Does this tiny ad smell okay to you?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic