Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL OpenQuery and Store Procedure

$
0
0

I'm trying to execute a stored procedure through Open Query, the problem is when I try to pass the parameters I get an error "Deferred prepare could not be completed.", I think the problem is when I try to use the varchar parameter @fechadesde, here's my code

declare @v varchar(200)
declare @legajo_desde VARCHAR(24)='104'
declare @legajo_hasta VARCHAR(24)='104'
declare @fechaDesde varchar(10)='01/01/2018'
declare @fechaHasta varchar(10)='31/01/2018'
declare @cod_dpto int=1
declare @incluir_sub_dpto CHAR(1)='N'


set @v='
SELECT *
FROM OPENQUERY(mylinkedserver, ''exec dbo.storedprocedure' + ' ' + @legajo_desde + ',' + @legajo_hasta + ', ' + '@fechaDesde' + ''')'
exec(@v)


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>