Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Alaveh
Starting Member
24 Posts |
Posted - 2011-10-04 : 09:38:38
|
| HiI Have the below Query that runs in SQL Server with this messages :Message 1 :Msg 2714, Level 16, State 3, Procedure GetTedad, Line 4There is already an object named 'GetTedad' in the database.Message 2 :Msg 2714, Level 16, State 3, Procedure getSumBSen2, Line 4There is already an object named 'getSumBSen2' in the database.But when i try to run it in ado query in delphi i receive this error :Incorrect syntax near 'GO'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;Can any body help me ? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-04 : 11:37:23
|
| thats because you've create function statements in code but the functions have already been created in sql. just change them to alter function and it will work.The reason you get error in Delphi is because GO might not be batch seperator in Delphi------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Alaveh
Starting Member
24 Posts |
Posted - 2011-10-04 : 18:40:03
|
| thank you visakh16When i changed create function to alter function i didn't receive any error but it still can't run it in ado query in delphi .if you or any one can , help me please .i can't understand your previous help ( because GO might not be batch separator ) what should i do ? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-05 : 00:29:36
|
| you're running this in delphi? Then please try posting it in delphi forums. Here we deal with primarily SQL Server------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Alaveh
Starting Member
24 Posts |
Posted - 2011-10-05 : 02:59:39
|
| oh yesmy faultsorry & thank you |
 |
|
|
|
|
|
|
|