开发者

How to use a parameter in Openrowset

开发者 https://www.devze.com 2023-03-25 19:06 出处:网络
I want to use a storedprocedure as a table in another storedprocedure. Here is my code: ALTER PROCEDURE [dbo].[Rapor_FaturalandirilmisFaturalandirilmamisSeansKarsilastirmasi]

I want to use a storedprocedure as a table in another storedprocedure. Here is my code:

 ALTER PROCEDURE [dbo].[Rapor_FaturalandirilmisFaturalandirilmamisSeansKarsilastirmasi]
    -- Add the parameters for the stored procedure here
    @tarih1 SMALLDATETIME,
    @tarih2 SMALLDATETIME
AS
BEGIN

    SET NOCOUNT ON;

  SELECT  K.euclidNo
          ,K.klinik_id
          ,K.KlinikAdi 

(
SELECT * FROM OPENROWSET('SQLNCLI', 'Server=***;UID=***;PWD=(***)',
     'EXECUTE Rapor_FaturalandirilmamisSeansSayilari ''' + CONVERT(VARCHAR,@tarih1,102开发者_如何转开发) + ''',''' +  CONVERT(VARCHAR,@tarih2,102)+ '''')

) AS FATURALANMAMIS
FROM Klinikler AS K
WHERE refKlinikGrup_id=1
END

But it returns "Incorrct syntax near '+' ". Do you have any suggestion about this problem?


Your error is probably related to the apostrophe's -- those always give me trouble.

But regardless -- your OPENROWSET should be in your FROM clause, shouldn't it? I'd start by fixing that.

0

精彩评论

暂无评论...
验证码 换一张
取 消