SQL Server Performance

how to pass parameters to openquery...

Discussion in 'SQL Server 2005 General Developer Questions' started by klsrao, Jan 19, 2009.

  1. klsrao New Member

    I am having a stored proc in sybase. this sp fetches data from sybase.
    I want to run the stored proc from SQL server.
    the following works if i change the sp without any parameters.
    select * from openquery (SybaseLinkServer,'execute DBName.dbo.StoredProcName ' )
    But i need to pass 3 parameters. The following doesnt work. select * from openquery (SybaseLinkServer,'execute DBName.dbo.StoredProcName 2,30,0' )
    Can anyone help with the exact syntax.
    Thanks in advance
  2. Adriaan New Member

    The command inside the OPENQUERY should conform to Sybase standards. No idea if there's anything special you need to consider - perhaps they separate parameters with semi-colons instead of commas?
    Other than that, are you sure those parameters on the Sybase end are all of a numeric type?
  3. klsrao New Member

    Thanks a lot for attempting.
    Yes. all the parameters are integers in Sybase.
    I executed the stored procedure in Sybase. It works.
    Can we pass parameters using openquery? If not openquery, do we need to use any other keyword like openrowset or something like that?
  4. Adriaan New Member

    So you can execute the exact same script -
    execute DBName.dbo.StoredProcName 2,30,0
    - in Sybase?
    It never hurts adding square brackets around the object names:
    execute [DBName].[dbo].[StoredProcName] 2,30,0

Share This Page