Danny Leandro
Danny Leandro

Reputation: 132

Calling SQLServer stored procedure from Sybase

I'm writing a script in Sybase ASE where I call a stored procedure in SQL Server. The problem I have is that I'm getting an error from Sybase but not from SQL Server.

The Script in Sybase is as follows:

declare @input varchar(4000)
select @input = '111,222,333,444,555'
exec GATEWAY.MyDataBase..MyStoredProcedure @input

And this is the error:

[Error] Script lines: 1-5 -------------------------- Conversion failed when converting the varchar value '555.............................................................................................................................................' to data type int. Msg: 245, Level: 16, State: 1 Server: GATEWAY, Line: 0

My stored procedure in SQLServer

I don't know why Sybase adds that right padding. The only way I can get it work is declaring the variable @input as varchar(255) or shorter.

What I tried without luck:

The important thing is that: I can excecute it from SQLServer but it throws error from Sybase with the same input data.

Any help would be very appreciated. I guess it has something to do with the size of the varchar but no clue yet.

Upvotes: 0

Views: 1213

Answers (1)

Weihui Guo
Weihui Guo

Reputation: 3997

You can create a remote procedure in Sybase like this:

CREATE PROCEDURE "DBA"."uspSQL_CreateTicketsByCaseNo;1"( in @caseNo varchar(8) ) 
at 'SQL;dbName;dbo;uspSQL_CreateTicketsByCaseNo'

You can also right-click the Procedures & Functions and use the wizard to create a remote procedure. Then call the remote procedure like this:

CALL "DBA"."uspSQL_CreateTicketsByCaseNo;1"( caseNo )

It works for me.

Upvotes: 0

Related Questions