Afficher un message
Vieux 25/03/2008, 15h00   #2
Plamen Ratchev
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Getting record position in sql server 2000

Here is one way to emulate ROW_NUMBER in SQL Server 2000, but be aware this
can be very slow with large data set:

CREATE TABLE Foo (
keycol CHAR(2) PRIMARY KEY,
datacol CHAR(1))

INSERT INTO Foo VALUES ('AA', 'a')
INSERT INTO Foo VALUES ('AC', 'c')
INSERT INTO Foo VALUES ('BC', 'd')
INSERT INTO Foo VALUES ('BA', 'e')

SELECT keycol,
datacol,
(SELECT COUNT(*)
FROM Foo AS B
WHERE B.keycol <= A.keycol) AS rn
FROM Foo AS A
ORDER BY keycol

HTH,

Plamen Ratchev
http://www.SQLStudio.com

  Réponse avec citation
 
Page generated in 0,04274 seconds with 9 queries