<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlserver.ro/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>T-SQL</title><link>http://sqlserver.ro/forums/15/ShowForum.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7130.aspx</link><pubDate>Fri, 08 May 2009 10:15:13 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7130</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7130.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7130</wfw:commentRss><description>&lt;P&gt;am mutat procedura pe serverul linked si merge mai bine.....multumesc&lt;/P&gt;
&lt;P&gt;alex.&lt;/P&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7112.aspx</link><pubDate>Thu, 07 May 2009 11:48:03 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7112</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7112.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7112</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://sqlserver.ro/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Alex:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;si cu procedura la fel :(&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br&gt;Ai folosit OPTIMIZE FOR ... ?&lt;br&gt;Unde ai definit procedura stocata ? &lt;br&gt;[1] În baza de date de pe server-ul linked sau [2] in baza de date unde apelezi server.dbo.tabela ? &lt;br&gt;Daca ai implementat procedura conform [2] atunci implementează procedura conform [1].&lt;br&gt;Dacă nici aşa atunci foloseşte o variabilă locală în locul parametrului astfel (&lt;i&gt;recomandarea nu-mi &lt;a href="http://www.jumpstarttv.com/solve-parameter-sniffing-by-using-local-variables_531.aspx"&gt;aparţine&lt;/a&gt;&lt;/i&gt;):&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color:Black;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;CREATE&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;PROCEDURE&lt;/span&gt; proceduraPesteluiPeLinked&lt;br&gt;    &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;declare&lt;/span&gt; @p_data &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;varchar&lt;/span&gt;(8)&lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;DECLARE&lt;/span&gt; @data &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;VARCHAR&lt;/span&gt;(8)&lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;SET&lt;/span&gt; @data = @p_data&lt;br&gt;&lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;select&lt;/span&gt; ClientId, Dept, (-1)*&lt;span style="color:Fuchsia;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;sum&lt;/span&gt;(Soldl) &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;as&lt;/span&gt; Sold &lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;from&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;table&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;where&lt;/span&gt; Bdata = @data&lt;br&gt;&lt;span style="color:Silver;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;and&lt;/span&gt; &lt;span style="color:Fuchsia;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;left&lt;/span&gt;(AccSint,4) &lt;span style="color:Silver;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;in&lt;/span&gt; (&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2021'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2031'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2042'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2052'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2061'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2091'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2312'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2811'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'2821'&lt;/span&gt;) &lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;group&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;by&lt;/span&gt; ClientId, Dept &lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7110.aspx</link><pubDate>Thu, 07 May 2009 09:14:12 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7110</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7110.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7110</wfw:commentRss><description>si cu procedura la fel :(</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7108.aspx</link><pubDate>Thu, 07 May 2009 08:07:48 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7108</guid><dc:creator>alexandrul</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7108.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7108</wfw:commentRss><description>Incearca si cu o procedura stocata avand ca parametru data respectiva, macar asa de amorul artei.&lt;br&gt;&lt;br&gt;http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=119740&lt;br&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7106.aspx</link><pubDate>Thu, 07 May 2009 06:33:26 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7106</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7106.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7106</wfw:commentRss><description>&lt;P&gt;un lucru f important pe care am uitat sa-l precizez si-mi cer scuze este ca&lt;/P&gt;
&lt;P&gt;tabela este catre un linked server&lt;/P&gt;
&lt;P&gt;daca rulez scriptul direct pe server&amp;gt;&amp;gt;databaseul unde se afla tabela merge f bine adica&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;declare&lt;/FONT&gt;&lt;FONT size=2&gt; @Data varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;8&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;set&lt;/FONT&gt;&lt;FONT size=2&gt; @Data &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'20090331'&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;select&lt;/FONT&gt;&lt;FONT size=2&gt; ClientId&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; Dept&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(-&lt;/FONT&gt;&lt;FONT size=2&gt;1&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;*&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;sum&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;Soldl&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; Sold 
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;from&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;STRONG&gt;tabela&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;where&lt;/FONT&gt;&lt;FONT size=2&gt; Bdata &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt; @Data&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;
&lt;P&gt;and&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;left(&lt;/FONT&gt;&lt;FONT size=2&gt;AccSint&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt;4&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;in&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2021'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2031'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2042'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2052'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2061'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2091'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2312'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2811'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2821'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;group&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;by&lt;/FONT&gt;&lt;FONT size=2&gt; ClientId&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; Dept&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;daca rulez scriptul prin linked server atunci merge f greu (dar daca inlocuiesc @data&amp;nbsp;cu '20090331' merge ok)&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;declare&lt;/FONT&gt;&lt;FONT size=2&gt; @Data varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;8&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;set&lt;/FONT&gt;&lt;FONT size=2&gt; @Data &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'20090331'&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;select&lt;/FONT&gt;&lt;FONT size=2&gt; ClientId&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; Dept&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(-&lt;/FONT&gt;&lt;FONT size=2&gt;1&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;*&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;sum&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;Soldl&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;FONT size=2&gt; Sold 
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;from&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;STRONG&gt;server.db.dbo.tabela&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;where&lt;/FONT&gt;&lt;FONT size=2&gt; Bdata &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt; @Data&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;
&lt;P&gt;and&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;left(&lt;/FONT&gt;&lt;FONT size=2&gt;AccSint&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt;4&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;in&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2021'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2031'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2042'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2052'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2061'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2091'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2312'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2811'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'2821'&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;group&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;by&lt;/FONT&gt;&lt;FONT size=2&gt; ClientId&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;FONT size=2&gt; Dept&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;multumesc.&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7105.aspx</link><pubDate>Thu, 07 May 2009 06:16:38 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7105</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7105.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7105</wfw:commentRss><description>&lt;P&gt;si cu char(8)&amp;nbsp;tot greu si cu len(Bdata) = 8 la fel&lt;/P&gt;
&lt;P&gt;si daca scot partea cu left(accsint,4) tot greu merge...am stat 10 min si nu am mai avut rabdate sa astept....&lt;/P&gt;
&lt;P&gt;daca scot parametrul adica Bdata = '20090331' si nu Bdata = @data dureaza 4 secunde&lt;/P&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7104.aspx</link><pubDate>Thu, 07 May 2009 05:56:07 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7104</guid><dc:creator>alexandrul</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7104.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7104</wfw:commentRss><description>incearca si varianta&lt;br&gt;&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;declare&lt;/font&gt;&lt;font size="2"&gt; @data char&lt;/font&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;font size="2"&gt;8&lt;/font&gt;&lt;font color="#808080" size="2"&gt;)&lt;/font&gt;&lt;/p&gt;&lt;p&gt;sau pune-i o conditie suplimentara de genul length(bdata)=8&lt;/p&gt;&lt;p&gt;Si ca sa fie testul complet, cum se modifica timpii de executie daca scoti din query partea cu left(accsint,4) ?&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7103.aspx</link><pubDate>Thu, 07 May 2009 05:39:32 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7103</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7103.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7103</wfw:commentRss><description>&lt;P&gt;Bdata in tabela este varchar(8) si nu o pot modifica&lt;/P&gt;
&lt;P&gt;am testat si cu &lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;declare&lt;/FONT&gt;&lt;FONT size=2&gt; @data varchar&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;FONT size=2&gt;8&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;set&lt;/FONT&gt;&lt;FONT size=2&gt; @data &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'20090331'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff0000&gt;si cu &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&lt;/FONT&gt;declare&lt;FONT color=#000000 size=2&gt; @data datetime&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;set&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; @data &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;'20090331'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;si cu&lt;/P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;select ClientId, Dept, (-1)*sum(Soldl) as Sold&amp;nbsp; &lt;BR&gt;from&amp;nbsp;table where &lt;B&gt;cast(Bdata as varchar(8))&lt;/B&gt; = @data&lt;BR&gt;and left(AccSint,4) in ('2021','2031','2042','2052','2061','2091','2312','2811','2821')&amp;nbsp; &lt;BR&gt;group by ClientId, Dept &lt;/P&gt;
&lt;P&gt;si la fel de prost merge&lt;BR&gt;&lt;/P&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7102.aspx</link><pubDate>Thu, 07 May 2009 03:57:00 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7102</guid><dc:creator>rremus</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7102.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7102</wfw:commentRss><description>Acuma nu stiu exact cum arata tabelele tale, dar daca ar fi sa ghicesc as zice ca e pentru ca declari parametrul ca varchar(8). Query-ul tau este echivalent cu:&lt;br&gt;&lt;br&gt;select ClientId, Dept, (-1)*sum(Soldl) as Sold&amp;nbsp; &lt;br&gt;from&amp;nbsp;table where &lt;b&gt;cast(Bdata as varchar(8))&lt;/b&gt; = @data&lt;br&gt;and left(AccSint,4) in ('2021','2031','2042','2052','2061','2091','2312','2811','2821')&amp;nbsp; &lt;br&gt;group by ClientId, Dept &lt;br&gt;&lt;br&gt;si va genera un plan care scaneaza tabela si converteste fiecare BData. Priml plan folosete un seek, al doilea un scan, de unde diferenta. Pentru a fixa problema declare @data ca datetime.&lt;br&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7101.aspx</link><pubDate>Wed, 06 May 2009 20:32:00 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7101</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7101.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7101</wfw:commentRss><description>În ceea ce priveşte OPTIMIZE FOR &lt;a href="http://msdn.microsoft.com/en-us/library/ms181714%28SQL.90%29.aspx"&gt;sintaxa&lt;/a&gt; din SQL 2005 este&lt;br&gt;&lt;pre class="libCScode" style="white-space:pre-wrap;" id="ctl00_mainContentContainer_ctl12other"&gt;  | OPTIMIZE FOR ( @variable_name = literal_constant [ &lt;b&gt;,&lt;/b&gt; ...n ] ) &lt;br&gt;&lt;/pre&gt;cu alte cuvinte, se pot specifica mai multe valori "semnificative".&lt;br&gt;&lt;br&gt;În SQL 2008 în sintaxa a fost introdusă şi opţiunea &lt;a href="http://blogs.msdn.com/sqlprogrammability/archive/2008/11/26/optimize-for-unknown-a-little-known-sql-server-2008-feature.aspx"&gt;OPTIMIZE FOR UNKNOWN&lt;/a&gt;:&lt;br&gt;&lt;pre class="libCScode" style="white-space:pre-wrap;" id="ctl00_mainContentContainer_ctl13other"&gt;  | OPTIMIZE FOR ( @variable_name { UNKNOWN | = literal_constant } [ , ...n ] )&lt;br&gt;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7099.aspx</link><pubDate>Wed, 06 May 2009 16:11:45 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7099</guid><dc:creator>rsocol</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7099.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7099</wfw:commentRss><description>&lt;P&gt;Vezi: &lt;A href="http://www.sqlmag.com/Article/ArticleID/94369/sql_server_94369.html"&gt;http://www.sqlmag.com/Article/ArticleID/94369/sql_server_94369.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(si alte multe articole despre "parameter sniffing")&lt;/P&gt;
&lt;P&gt;Razvan&lt;/P&gt;</description></item><item><title>Re: select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7098.aspx</link><pubDate>Wed, 06 May 2009 15:14:10 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7098</guid><dc:creator>alexandrul</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7098.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7098</wfw:commentRss><description>Ce tip de data are Bdata?&lt;br&gt;</description></item><item><title>select care merge f greu cu parametru - sql server 2005</title><link>http://sqlserver.ro/forums/thread/7097.aspx</link><pubDate>Wed, 06 May 2009 14:50:30 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:7097</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/7097.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=7097</wfw:commentRss><description>&lt;P&gt;Salut,&lt;/P&gt;
&lt;P&gt;am si eu o nelamurire&lt;/P&gt;
&lt;P&gt;de ce selectul urmator merge f bine cateva secunde&lt;/P&gt;
&lt;P&gt;select ClientId, Dept, (-1)*sum(Soldl) as Sold&amp;nbsp; &lt;BR&gt;from&amp;nbsp;table where Bdata = '20090331' and left(AccSint,4) in ('2021','2031','2042','2052','2061','2091','2312','2811','2821')&amp;nbsp; &lt;BR&gt;group by ClientId, Dept &lt;/P&gt;
&lt;P&gt;iar daca am&lt;/P&gt;
&lt;P&gt;declare @data varchar(8)&lt;/P&gt;
&lt;P&gt;set @data = '20090331'&lt;/P&gt;
&lt;P&gt;select ClientId, Dept, (-1)*sum(Soldl) as Sold&amp;nbsp; &lt;BR&gt;from&amp;nbsp;table where Bdata = @data&lt;BR&gt;and left(AccSint,4) in ('2021','2031','2042','2052','2061','2091','2312','2811','2821')&amp;nbsp; &lt;BR&gt;group by ClientId, Dept &lt;/P&gt;
&lt;P&gt;merge f greu...zeci de minute&lt;/P&gt;
&lt;P&gt;multumesc&lt;/P&gt;
&lt;P&gt;alex.&lt;/P&gt;</description></item></channel></rss>