I have been using an SQL Server that has a Sybase server set up as a linked server.
I can query the linked server's tables by this
SELECT * FROM [LinkDb].[Database].[dbo].TABLENAME
Today I encountered an issue, when I was trying to use variables to filter date from and to values.
I narrowed it down to this query:
declare @dateVal nvarchar(90)
set @dateVal = (select convert(varchar, getdate(), 126) + '0000')
select * from [LinkDb].[Database].[dbo].TABLENAME
where datevalue >= '2014-10-06T00:00:00.0000000'
and datevalue <= @dateVal
Which returns the error message:
OLE DB provider "Sybase.ASEOLEDBProvider" for linked server "SSE" returned message "The parameter is incorrect.
".
Not sure on what should be ticked here, but these are the Provider Parameters for my Sybase Connection.
Any help is much appreciated.
I have managed to get around this, by using a nested query.
May work for anyone experiencing the same.
select * from [LinkDb].[Database].[dbo].TABLENAME
where datevalue >= '2014-10-06T00:00:00.0000000'
and datevalue <= (SELECT MAX(datevalue) FROM [LinkDb].[Database].[dbo].TABLENAME)