why exec sp_executesql param name be changed?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ys990819
Posts: 8
Joined: Tue 26 Nov 2013 02:36

why exec sp_executesql param name be changed?

Post by ys990819 » Tue 26 Nov 2013 02:46

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!

ys990819
Posts: 8
Joined: Tue 26 Nov 2013 02:36

Re: why exec sp_executesql param name be changed?

Post by ys990819 » Tue 26 Nov 2013 02:47

My English is poor.
Thanks a lot.

AndreyZ

Re: why exec sp_executesql param name be changed?

Post by AndreyZ » Wed 27 Nov 2013 13:48

Such behaviour is caused by the provider, OLEDB or SQL Native Client. We cannot influence it.

ys990819
Posts: 8
Joined: Tue 26 Nov 2013 02:36

Re: why exec sp_executesql param name be changed?

Post by ys990819 » Wed 27 Nov 2013 14:41

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.

AndreyZ

Re: why exec sp_executesql param name be changed?

Post by AndreyZ » Thu 28 Nov 2013 11:41

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.

flavio.boel
Posts: 1
Joined: Fri 21 Feb 2014 14:44

Re: why exec sp_executesql param name be changed?

Post by flavio.boel » Fri 21 Feb 2014 14:47

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: why exec sp_executesql param name be changed?

Post by AlexP » Mon 24 Feb 2014 08:33

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.

ys990819
Posts: 8
Joined: Tue 26 Nov 2013 02:36

Re: why exec sp_executesql param name be changed?

Post by ys990819 » Tue 18 Mar 2014 10:36

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?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: why exec sp_executesql param name be changed?

Post by AlexP » Fri 21 Mar 2014 14:18

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

Post Reply