<?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: CASE in WHERE</title><link>http://sqlserver.ro/forums/thread/5249.aspx</link><pubDate>Thu, 03 Jul 2008 09:44:23 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:5249</guid><dc:creator>ssandu</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/5249.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=5249</wfw:commentRss><description>Deoarece am cam multe variante am adoptat varianta cu un tabel separat.&lt;br&gt;Va multumesc ptr. raspunsuri&lt;br&gt;</description></item><item><title>Re: CASE in WHERE</title><link>http://sqlserver.ro/forums/thread/5247.aspx</link><pubDate>Thu, 03 Jul 2008 09:32:06 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:5247</guid><dc:creator>rsocol</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/5247.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=5247</wfw:commentRss><description>Sau altă variantă (ceva mai eficientă decât cea a lui Andrei şi probabil mai aproape de rezultatul dorit):&lt;br&gt;&lt;br&gt;select * from tabel &lt;br&gt;where USER_NAME() = 'user1' and utilizator in  ('user1', 'user2')&lt;br&gt;or USER_NAME() = 'user2' and utilizator in  ('user3', 'user2')&lt;br&gt;or USER_NAME() not in ('user1','user2') and utilizator = USER_NAME() &lt;br&gt;&lt;br&gt;Răzvan&lt;br&gt;</description></item><item><title>Re: CASE in WHERE</title><link>http://sqlserver.ro/forums/thread/5246.aspx</link><pubDate>Thu, 03 Jul 2008 08:22:54 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:5246</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/5246.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=5246</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;ssandu:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Ma gandeam sa nu mai fie nevoie de inca un tabel&lt;br&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&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;SELECT&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;FROM&lt;/span&gt; tabel&lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;WHERE&lt;/span&gt; utilizator &lt;span style="color:Silver;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;IN&lt;/span&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;(&lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;SELECT&lt;/span&gt; Lista &lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;FROM&lt;/span&gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;SELECT&lt;/span&gt; &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user1'&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Utilizator, &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user1'&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Lista&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;UNION&lt;/span&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;SELECT&lt;/span&gt; &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user1'&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Utilizator, &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user2'&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Lista&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;UNION&lt;/span&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;SELECT&lt;/span&gt; &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user3'&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Utilizator, &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user3'&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Lista&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;UNION&lt;/span&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;SELECT&lt;/span&gt; &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user3'&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Utilizator, &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user2'&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Lista&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;) &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;AS&lt;/span&gt; Q&lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;WHERE&lt;/span&gt; Utilizator = &lt;span style="color:Fuchsia;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;USER_NAME&lt;/span&gt;())&lt;/span&gt;&lt;br&gt;</description></item><item><title>Re: CASE in WHERE</title><link>http://sqlserver.ro/forums/thread/5245.aspx</link><pubDate>Thu, 03 Jul 2008 08:19:48 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:5245</guid><dc:creator>ignatandrei</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/5245.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=5245</wfw:commentRss><description>Workaround :&lt;br&gt;&lt;br&gt;select * from tabel &lt;br&gt;where USER_NAME() = 'user1' and utilizator in  ('user1', 'user2')&lt;br&gt;union all&lt;br&gt;select * from tabel &lt;br&gt;
where USER_NAME() = 'user2' and utilizator in  ('user3', 'user2')&lt;br&gt;union all&lt;br&gt;select * from tabel &lt;br&gt;
where utilizator&amp;nbsp; = USER_NAME() &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</description></item><item><title>Re: CASE in WHERE</title><link>http://sqlserver.ro/forums/thread/5244.aspx</link><pubDate>Thu, 03 Jul 2008 08:19:00 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:5244</guid><dc:creator>ssandu</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/5244.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=5244</wfw:commentRss><description>Ma gandeam sa nu mai fie nevoie de inca un tabel&lt;br&gt;</description></item><item><title>Re: CASE in WHERE</title><link>http://sqlserver.ro/forums/thread/5243.aspx</link><pubDate>Thu, 03 Jul 2008 08:14:30 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:5243</guid><dc:creator>B_gd_n[ ]Sahlean</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/5243.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=5243</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;ssandu:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Cum pot sa fac urmatorul select (acum da eroare)&lt;br&gt;SELECT * from tabel&lt;br&gt;WHERE utilizator IN&lt;br&gt;CASE&lt;br&gt;WHEN USER_NAME() = 'user1' THEN ('user1', 'user2')&lt;br&gt;WHEN USER_NAME() = 'user3' THEN ('user3', 'user2')&lt;br&gt;DEFAULT USER_NAME()&lt;br&gt;END&lt;br&gt;&lt;br&gt;Se poate ?&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br&gt;Poti pleca de la urmatoarea solutie (ce-i bazaconia aia cu DEFAULT ?):&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;TABLE&lt;/span&gt; ListaUtilizatori&lt;br&gt;(&lt;br&gt;Utilizator &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;VARCHAR&lt;/span&gt;(25),&lt;br&gt;Lista &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;VARCHAR&lt;/span&gt;(25)&lt;br&gt;);&lt;br&gt;GO &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;&lt;/span&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;INSERT&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;INTO&lt;/span&gt; ListaUtilizatori &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;VALUES&lt;/span&gt;(&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user1'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user1'&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;INSERT&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;INTO&lt;/span&gt; ListaUtilizatori &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;VALUES&lt;/span&gt;(&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user1'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user2'&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;INSERT&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;INTO&lt;/span&gt; ListaUtilizatori &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;VALUES&lt;/span&gt;(&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user3'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user3'&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;INSERT&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;INTO&lt;/span&gt; ListaUtilizatori &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;VALUES&lt;/span&gt;(&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user3'&lt;/span&gt;,&lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;'user2'&lt;/span&gt;)&lt;br&gt;GO&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;SELECT&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;FROM&lt;/span&gt; tabel&lt;br&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;WHERE&lt;/span&gt; utilizator &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:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;SELECT&lt;/span&gt; Lista &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;FROM&lt;/span&gt; ListaUtilizatori &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;WHERE&lt;/span&gt; Utilizator = &lt;span style="color:Fuchsia;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;USER_NAME&lt;/span&gt;())&lt;/span&gt;&lt;br&gt;</description></item><item><title>CASE in WHERE</title><link>http://sqlserver.ro/forums/thread/5242.aspx</link><pubDate>Thu, 03 Jul 2008 07:51:01 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:5242</guid><dc:creator>ssandu</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/5242.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=5242</wfw:commentRss><description>Cum pot sa fac urmatorul select (acum da eroare)&lt;br&gt;SELECT * from tabel&lt;br&gt;WHERE utilizator IN&lt;br&gt;CASE&lt;br&gt;WHEN USER_NAME() = 'user1' THEN ('user1', 'user2')&lt;br&gt;WHEN USER_NAME() = 'user3' THEN ('user3', 'user2')&lt;br&gt;DEFAULT USER_NAME()&lt;br&gt;END&lt;br&gt;&lt;br&gt;Se poate ?&lt;br&gt;&lt;br&gt;</description></item></channel></rss>