0
此表值函数编译好的时候抛出..附近有语法错误,SQL 2005 - 表值函数编译确定,但选择
alter function [dbo].[ftsls031nnnHades](@withExpiredEntries smallint) returns
@t table(comno varchar(3),
t$cuno varchar(6),
t$cpgs varchar(6),
t$dile float,
t$qanp float,
t$stdt varchar(10),
t$tdat varchar(10),
t$disc float,
t$damt float,
t$cdis char(3),
t$gnpr float,
t$refcntd float,
t$refcntu float) as
------------------------------------------------------*/
/*-------------------------------------------------------
declare @withExpiredEntries bit; set @withExpiredEntries =0
declare @t table(comno varchar(3),
t$cuno varchar(6),
t$cpgs varchar(6),
t$dile float,
t$qanp float,
t$stdt varchar(10),
t$tdat varchar(10),
t$disc float,
t$damt float,
t$cdis char(3),
t$gnpr float,
t$refcntd float,
t$refcntu float)
------------------------------------------------------*/
Begin
set quoted_identifier off
if (@withExpiredEntries = 0) -- without expired entries
Begin
insert @t
select *
from openQuery(Hades ,"select '010' comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,'dd Mon yy') t$stdt,to_char(t$tdat,'dd Mon yy') t$tdat,to_char(t$disc,'999.99') t$disc,t$damt,t$cdis,t$gnpr,t$refcntd,t$refcntu from baan.ttdsls031010 where (to_char(t$Tdat,'yyyy-mm-dd') >= To_char(current_date,'yyyy-mm-dd')) and (to_char(t$stdt,'yyyy-mm-dd') <= To_char(current_date,'yyyy-mm-dd'))
union all select '020' comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,'dd Mon yy') t$stdt,to_char(t$tdat,'dd Mon yy') t$tdat,to_char(t$disc,'999.99') t$disc,t$damt,t$cdis,t$gnpr,t$refcntd,t$refcntu from baan.ttdsls031020 where (to_char(t$tdAt,'yyyy-mm-dd') >= To_char(current_date,'yyyy-mm-dd')) and (to_char(t$stdt,'yyyy-mm-dd') <= To_char(current_date,'yyyy-mm-dd'))")
return
End
insert @t
select *
from openQuery(Hades ,"select '010' comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,'dd Mon yy') t$stdt,to_char(t$tdat,'dd Mon yy') t$tdat,to_char(t$disc,'999.99') t$disc,t$damt,t$cdis,t$gnpr,t$refcntd,t$refcntu from baan.ttdsls031010
union all select '020' comno, trim(t$cuno) t$cuno,trim(t$cpgs) t$cpgs,t$dile,t$qanp,to_char(t$stdt,'dd Mon yy') t$stdt,to_char(t$tdat,'dd Mon yy') t$tdat,to_char(t$disc,'999.99') t$disc,t$damt,t$cdis,t$gnpr,t$refcntd,t$refcntu from baan.ttdsls031020 ")
return
end
选择
消息102时,它抛出这个错误,等级15,状态1,行1 'select'010'comno,trim(t $ cuno)t $ cuno,trim(t $ cpgs)t $ cpgs,t $ dile,t $ qanp,to_char(t $ stdt, 'dd Mon yy')t $ stdt,to_char(t $ tdat,'dd'。
感谢您对Quoted_identifer的说明.. 我确实改变了select语句来翻转single和双引号与对方..但仍然是相同的.. – TonyP 2010-08-28 14:38:03
TonyP:我的意思是双倍,那就是“不” – gbn 2010-08-28 14:46:35