Thanks Tim,


I have created the stored procedure based on your code below.

Thanh.

-----Original Message-----
From: Raster, Tim [mailto:[EMAIL PROTECTED]
Sent: Monday, August 30, 2004 12:53 PM
To: SQL
Subject: RE: auto-numbering the rows that the SELECT statement retrieves?

If you're in SQL Server with a Stored Procedure, you can.

Instead of:

Select field1, field2, ..., fieldN
>From MyTable
Where blah blah

You could have within a Stored Procedure:

Create table #TempTable (MyAutoNumber int not null identity (1,1),
Field1 varchar(255), Field2 int, ..., FieldN datetime)

Insert into #TempTable (Field1, Field2, ..., FieldN)
Select field1, field2, ..., fieldN
>From MyTable
Where blah blah

            Select * from #TempTable order by MyAutoNumber

-----Original Message-----
From: Thanh Nguyen [mailto:[EMAIL PROTECTED]
Sent: Monday, August 30, 2004 14:49
To: SQL
Subject: auto-numbering the rows that the SELECT statement retrieves?

Can I create a simple SELECT statement that generates an IDENTITY-type
value by auto-numbering the rows that the SELECT statement retrieves?

Thanh Nguyen
________________________________
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to