DECLARE @FORM_KIND VARCHAR(50)
DECLARE @FORM_NO VARCHAR(50)
DECLARE @Sql NVARCHAR(1000)
declare @X nvarchar(500)
declare @Y nvarchar(500)
set @form_kind='SYS.FORM.008';
set @form_no=12500;
SET @Sql ='select 1 as num, tah.travel_purpose || ''$$'' || tah.bu_code || ''$$'' || tah.ou_code document_summary from bpm.bpm_tes_flow f,bpm.bpm_tes_ta_head tah where tah.ta_head_id=f.source_id and f.source_category=''TA''
and f.form_kind='''+@form_kind+''' and f.form_no=12500';
print @Sql
SET @Sql = 'SELECT @A=document_summary,@B=num FROM OPENQUERY(ORACLE_ERP, ''' + REPLACE(@Sql, '''', '''''') + ''')'
exec sp_executesql @Sql,N'@A NVARCHAR(500) output,@B NVARCHAR(50) OUTPUT',@X output,@Y OUTPUT
PRINT @X+'============'+@Y