Delphi与SQL Server之间的冲突 [英] Conflict between Delphi and SQL server

查看:90
本文介绍了Delphi与SQL Server之间的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也有一个在SQL Server中也可以使用的查询,但是当我将其保存在delphi的ado查询中时,它不起作用,并因以下错误而停止:

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'

但以下代码正确而且没有任何错误。我在sql server中测试过。
下面的代码不是常规代码,因为我从delphi复制并粘贴了它。

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 .

我的查询:

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;


推荐答案

GO 关键字不是SQL Server语句

The GO keyword is not a SQL Server statement


GO不是Transact-SQL语句;这是
sqlcmd和osql实用程序以及SQL Server Management Studio代码
编辑器可以识别的命令。

GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.

您必须从Delphi代码中删除此语句才能执行Sql语句。查看此问题的示例 如何从Delphi运行数据库脚本文件?

You must remove this statement from your Delphi Code in order to execute your Sql sentence. check this question for an example How to run a database script file from Delphi?

这篇关于Delphi与SQL Server之间的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆