Groups | Blog | Home
all groups > sql server mseq > december 2003 >

sql server mseq : Sql-Disp


Prem
12/15/2003 3:57:00 AM
How to display the Record nUmber alongwith other fields.
For example if i have table with name and address, I would
like to have the o/p as

Record# Name Address
1 xx yyy
....

Prem KumariJ
12/15/2003 9:03:12 PM
Thanxs for the timely help

Regards,
Prem



*** Sent via Developersdex http://www.developersdex.com ***
Vishal Parkar
12/15/2003 9:16:26 PM
Prem,

There isn't anything called "record number" assignement to each row in sql. To generate
row numbers on the basis of the existing row integrity in the table you can have following
approach or refer to url that i've mentioned.

-- see following example on northwind database. if the combination of contactname and
address
-- is unique then following query may satisfy your requirement.
Ex:
use northwind
go
select
(select count(*) from customers a
where a.contactname + a.address <= customers.contactname + customers.address
)
rownum,
contactname,address
from customers
order by 1
go

-- Refer to following url
HOW TO: Dynamically Number Rows in a Select Statement
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q186133

--
- Vishal

AddThis Social Bookmark Button