why exec sp_executesql param name be changed?
why exec sp_executesql param name be changed?
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!
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?
My English is poor.
Thanks a lot.
Thanks a lot.
-
AndreyZ
Re: why exec sp_executesql param name be changed?
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?
I ask for this ,because when some complicated sql sentence has many same params,like this:AndreyZ wrote:Such behaviour is caused by the provider, OLEDB or SQL Native Client. We cannot influence it.
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.
-
AndreyZ
Re: why exec sp_executesql param name be changed?
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.
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.
-
flavio.boel
- Posts: 1
- Joined: Fri 21 Feb 2014 14:44
Re: why exec sp_executesql param name be changed?
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.
Due to the delay we are looking for a component with better performance in MSSQL.
Re: why exec sp_executesql param name be changed?
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?
Is this problem be resolved?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.
Re: why exec sp_executesql param name be changed?
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