Page 1 of 1
why exec sp_executesql param name be changed?
Posted: Tue 26 Nov 2013 02:46
by ys990819
when i use code for this:
procedure TForm1.btn1Click(Sender: TObject);
begin
qry1.Close;
qry1.SQL.Clear;
qry1.SQL.Add('select WL_WLID from WL where WL_WLID=:pWLID');
qry1.ParamByName('PWLID').AsString := 'aaa';
qry1.Open;
end;
if I run the program,then SQL SERVER Profiler trace the sql is :
exec sp_executesql N'select WL_WLID from WL where WL_WLID=@P1',N'@P1 varchar(3)','aaa'
the param name be changed to "P1",
how can I change the Delphi Code , Set which property to change the trace result?to make the result to be like this:
exec sp_executesql N'select WL_WLID from WL where WL_WLID=@PWLID',N'@PWLID varchar(3)','aaa'
Thanks!
Re: why exec sp_executesql param name be changed?
Posted: Tue 26 Nov 2013 02:47
by ys990819
My English is poor.
Thanks a lot.
Re: why exec sp_executesql param name be changed?
Posted: Wed 27 Nov 2013 13:48
by AndreyZ
Such behaviour is caused by the provider, OLEDB or SQL Native Client. We cannot influence it.
Re: why exec sp_executesql param name be changed?
Posted: Wed 27 Nov 2013 14:41
by ys990819
AndreyZ wrote:Such behaviour is caused by the provider, OLEDB or SQL Native Client. We cannot influence it.
I ask for this ,because when some complicated sql sentence has many same params,like this:
select WL_WLID,WL_MC from WL
where WL_WLID=:pWLID
union all
select XX_WLID,XX_MC from XX
where XX_WLID=:pWLID
......
when the query opened,the sql profile trace like this:
exec sp_executesql N'select WL_WLID,WL_MC from WL where WL_WLID=@P1 union all select XX_WLID,XX_MC from XX where XX_WLID=@P2 ...',N'@P1 varchar(3),@P2 varchar(3)...@P25','aaa','aaa',...
the query opened spent about 30 seconds.
but I change the sql sentence like this:
exec sp_executesql N'select WL_WLID,WL_MC from WL where WL_WLID=@PWLID union all select XX_WLID,XX_MC from XX where XX_WLID=@PWLID...',N'@PWLID varchar(3)','aaa'
the query opened spent about 5 seconds.
So,Could you help to solve this problem?
Please. thanks.
Re: why exec sp_executesql param name be changed?
Posted: Thu 28 Nov 2013 11:41
by AndreyZ
As I wrote you above, we do not control naming of the parameters, it is controlled by the used provider (OLEDB or SQL Native Client).
You can avoid the performance problem by not using parameters. We already have a suggestion of sending queries to the server without using parameters. You can vote for it at
http://devart.uservoice.com/forums/1046 ... hout-param Suggestions with many votes will be implemented faster.
Re: why exec sp_executesql param name be changed?
Posted: Fri 21 Feb 2014 14:47
by flavio.boel
The implementation of this feature is essential for us because running with exec sp_executesql ignores indexes and statistics on MSSQL Server.
Due to the delay we are looking for a component with better performance in MSSQL.
Re: why exec sp_executesql param name be changed?
Posted: Mon 24 Feb 2014 08:33
by AlexP
We are working at this for the time being. This feature will be added for all the DAC products. Therefore it is a rather time-consuming feature.
Re: why exec sp_executesql param name be changed?
Posted: Tue 18 Mar 2014 10:36
by ys990819
AlexP wrote:We are working at this for the time being. This feature will be added for all the DAC products. Therefore it is a rather time-consuming feature.
Is this problem be resolved?
Re: why exec sp_executesql param name be changed?
Posted: Fri 21 Mar 2014 14:18
by AlexP
It's not a bug - it's a new functionality. We are working at this. However, we cannot say the exact timing of its implementation