Delphi: Delphi and Microsoft SQL Server 2005 bad c

2019-07-26 19:28发布

When i send this query on SQL Server 2005 with the Microsoft SQL Server Management Studio

SELECT dbo.MOV('Hi',10,2) + dbo.MOV('Hi2',8,2)

The query returns 400

The result of anything send to the function will return 200 except if the last two parameter where 0 the value of return will be 100 and the value type of return from the function its Decimal(12,2)

the problem, comes when I do the query on Delphi

Query.SQL.Add('SELECT dbo.MOV(''Hi'',10,2) + dbo.MOV(''Hi2'',8,2)');
Query.Open;
Query.Next;
ShowMessage(Query.Fields[0].AsString);

The Query returns 200 (on the message dialog), like if SQL Server is just taking the first Function and ignoring the second one, so what i could do get from SQL Server 2005 the right calculation in Delphi. Thanks.

1条回答
疯言疯语
2楼-- · 2019-07-26 20:12

Try to clear Query.SQL before Query.SQL.Add.

Query.SQL.Clear
Query.SQL.Add('SELECT dbo.MOV(''Hi'',10,2) + dbo.MOV(''Hi2'',8,2)');

If you already have a query stored in SQL you will only see the result from the first one.

查看更多
登录 后发表回答