I have a Query that works in SQL Server as well but when i save it in ado query in delphi it doesn't work and stops with this error :
Incorrect syntax near 'GO'
But the below code is correct and has not any error . i was tested it in sql server . The below code is not Regular because i copy and past it from delphi .
My Query :
create function GetTedad(@pfcode INT, @pdcode INT) returns int
as begin declare @Tedad int;
select @Tedad= sum(t2.tedade_avalie) from Tbl_avalie_salon t2 where t2.FCode = @pfcode and t2.DCode = @pdcode
return (@Tedad); end;
GO
create function getSumBSen2(@pfcode INT, @pdcode INT, @pSen INT) returns int
as begin declare @r int;
select @r= sum(t2.t_shab + t2.t_rooz) from tbl_talafat_dan t2 where t2.FCode = @pfcode and t2.DCode = @pdcode and t2.sen <= @pSen;
return (@r); end;
GO
select t1.sen, sum(t1.d_rooz) as d1, sum(t1.d_shab) as d2, sum(t1.d_rooz + t1.d_shab) as d_sum,
Round((sum((1000*(t1.d_rooz+t1.d_shab)+0.01)/((dbo.GetTedad(81, 1))-(dbo.getSumBSen2(81, 1, t1.sen))))),1) as Saraneh
from tbl_talafat_dan t1 where t1.FCode =81 and t1.DCode = 1 group by t1.sen;