1

次の手順があります。

CREATE PROCEDURE [dbo].[meals] @EncounterID nvarchar(15), @EventDate nvarchar(30)
AS
   DECLARE @TSQL varchar(8000);

   SELECT  @TSQL = 'SELECT * FROM OPENQUERY(cerner, ''select ce.result_val  PercentEaten,
ce.event_cd Meal
 from clinical_event ce
 where
 ce.task_assay_cd in ( 5362408, 5362296, 5361870)
 and ce.event_end_dt_tm >= sysdate-30
 and ce.event_cd in (636033, 636036, 636039)
 and ce.event_class_cd = 233
and ce.encntr_id = ''' +CAST(@EncounterID as varchar(15))+ '''
and ce.event_end_dt_tm between to_char('''+CAST(@EventDate as varchar(30))+''' - .5) and 
    to_char('''+CAST(@EventDate as varchar(30))+''' - 1)
'')';
EXEC (@TSQL);
GO

この行で実行すると:

exec dbo.meals @EncounterID =  '12345678',@EventDate = '07/18/2013'

というエラーが表示されますerror at line 9

私は何を間違っていますか??

4

1 に答える 1