<?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: cum pot numerota ce intoarce un select?!?!?!</title><link>http://sqlserver.ro/forums/thread/2085.aspx</link><pubDate>Wed, 13 Jun 2007 05:57:02 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2085</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2085.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2085</wfw:commentRss><description>&lt;P&gt;initial asa am vrut...sa mai adaug o coloana ...era varianta cea mai buna....dar nu am voie sa modific tabela respectiva :(....&lt;/P&gt;
&lt;P&gt;oricum sper sa ma descurc si cu selectul ala :)&lt;/P&gt;
&lt;P&gt;multumesc mult.&lt;/P&gt;
&lt;P&gt;alex.&lt;/P&gt;</description></item><item><title>Re: cum pot numerota ce intoarce un select?!?!?!</title><link>http://sqlserver.ro/forums/thread/2083.aspx</link><pubDate>Tue, 12 Jun 2007 15:23:04 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2083</guid><dc:creator>Diana</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2083.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2083</wfw:commentRss><description>...iar intr-un "SELECT INTO" poti folosi si functia IDENTITY()&amp;nbsp; (---&amp;gt; IDENTITY(int, 1, 1))</description></item><item><title>Re: cum pot numerota ce intoarce un select?!?!?!</title><link>http://sqlserver.ro/forums/thread/2082.aspx</link><pubDate>Tue, 12 Jun 2007 14:43:16 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2082</guid><dc:creator>Diana</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2082.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2082</wfw:commentRss><description>&lt;p&gt;Daca lucrezi pe SQL 2000, poti de asemenea:&lt;/p&gt;&lt;p&gt;1. sa adaugi o coloana IDENTITY(1,1) la tabel&lt;/p&gt;&lt;p&gt;2.
sa inserezi inregistrarile intr-o tablea temporara/variabila tabel cu
coloanele ID (---&amp;gt; IDENTITY(1,1)), nume, prenume si sa selectezi de
acolo&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: cum pot numerota ce intoarce un select?!?!?!</title><link>http://sqlserver.ro/forums/thread/2081.aspx</link><pubDate>Tue, 12 Jun 2007 14:31:55 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2081</guid><dc:creator>rsocol</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2081.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2081</wfw:commentRss><description>&lt;p&gt;Lipseşte ceva important din tabela ta: primary key-ul; şi nu mă refer la o coloană ID, identity, care ar trebui fi primary key doar dacă există o altă cheie unică bazată pe coloane introduse de utilizator. În cazul în care primary key-ul este coloana nume, atunci query-ul găsit de tine este foarte bun. O altă variantă, care merge doar începând din SQL 2005, ar fi:&lt;/p&gt;&lt;p&gt;SELECT ROW_NUMBER() OVER (ORDER BY Nume) as rowNumber, *&lt;br&gt;FROM Persoane&lt;br&gt;ORDER BY rowNumber&lt;/p&gt;&lt;p&gt;Acest query ar rezolva problema şi în cazul în care ar fi mai multe persoane cu acelaşi Nume dar cu Prenume diferite (dându-le rowNumber-uri diferite, dar fără o ordine anume). Dacă vrem să se comporte oarecum asemănător cu query-ul tău, am putea să folosim funcţia RANK în loc de ROW_NUMBER. &lt;br&gt;&lt;/p&gt;&lt;p&gt;Dacă avem cheia unică Nume+Prenume (aşa cum ar fi normal pentru o astfel de tabelă), ar trebui să luăm în considerare la numerotarea rândurilor ambele coloane. În cazul în care folosim SQL 2005, e banal, punem "OVER (ORDER BY Nume, Prenume)", dar dacă folosim SQL 2000, query-ul se complică puţin:&lt;/p&gt;&lt;p&gt;SELECT (&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT COUNT(*) FROM Persoane b&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE&amp;nbsp; b.nume &amp;lt; a.nume&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; OR b.nume=a.nume and b.prenume&amp;lt;a.prenume&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )+1&amp;nbsp; as rowNumber, *&lt;br&gt;FROM Persoane a&lt;br&gt;ORDER BY rowNumber&lt;br&gt;&lt;/p&gt;&lt;p&gt;Răzvan&lt;/p&gt;</description></item><item><title>Re: cum pot numerota ce intoarce un select?!?!?!</title><link>http://sqlserver.ro/forums/thread/2080.aspx</link><pubDate>Tue, 12 Jun 2007 14:12:01 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2080</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2080.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2080</wfw:commentRss><description>&lt;P&gt;am gasit :)&lt;/P&gt;
&lt;P&gt;select ( select count(*)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp; Table1 c&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp; c.nume &amp;lt;= table1.nume)&amp;nbsp; as rowNumber,*&lt;BR&gt;from&amp;nbsp;&amp;nbsp; table1&lt;BR&gt;order by rowNumber&lt;/P&gt;
&lt;P&gt;alex.&lt;/P&gt;</description></item><item><title>cum pot numerota ce intoarce un select?!?!?!</title><link>http://sqlserver.ro/forums/thread/2079.aspx</link><pubDate>Tue, 12 Jun 2007 13:46:58 GMT</pubDate><guid isPermaLink="false">963f3a18-65dd-4aad-905c-b785cfe1d7c7:2079</guid><dc:creator>Alex</dc:creator><slash:comments>0</slash:comments><comments>http://sqlserver.ro/forums/thread/2079.aspx</comments><wfw:commentRss>http://sqlserver.ro/forums/commentrss.aspx?SectionID=15&amp;PostID=2079</wfw:commentRss><description>&lt;P&gt;salut, cum pot numerota ce intoarce un select?!?!?! in SQL Server 2000 (in 2005 am vazut ceva row_number)&lt;/P&gt;
&lt;P&gt;am o tabela cu coloanele Nume,Prenume&lt;/P&gt;
&lt;P&gt;CREATE TABLE [dbo].[Table1] (&lt;BR&gt;&amp;nbsp;[Nume] [nvarchar] (50) NULL ,&lt;BR&gt;&amp;nbsp;[Prenume] [nvarchar] (50) NULL &lt;BR&gt;)&lt;BR&gt;GO&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;cum pot afisa dintr-un select * from tabel1 astfel&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Nume&amp;nbsp;&amp;nbsp;&amp;nbsp; Prenume&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nume1&amp;nbsp;&amp;nbsp;&amp;nbsp; prenume1&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nume2&amp;nbsp;&amp;nbsp;&amp;nbsp; prenume2&lt;/P&gt;
&lt;P&gt;........&lt;/P&gt;
&lt;P&gt;adica selectul sa-mi mai faca o colana care sa-mi numeroteze&lt;/P&gt;
&lt;P&gt;multumesc&lt;/P&gt;
&lt;P&gt;alex.&lt;/P&gt;</description></item></channel></rss>