Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dybamic row id from SQL

8 views
Skip to first unread message

Russ

unread,
Jul 22, 2003, 1:57:28 PM7/22/03
to
Hi all !

Assume there is a table with only column with non-unique data in it.

Is any SQL statement could retrieveall data from this table and numarate
each row in a result set ?

Additional limitatoins: MS SQL; no stored proc or temp tables can be used.

Thank you.

Sanjiv Das [TeamSybase]

unread,
Jul 22, 2003, 5:35:40 PM7/22/03
to
Russ,

Are you trying to generate numbers at runtime ? Couldn't you just use an
identity column in the table ? Then you can include that column in your
result set.

Are you pulling the data into a datawindow ? If so, you could set up any IDs
you want by programmatically scrolling through the rows in the DW and
assigning IDs.

Just curious - why the limitation that you can't use stored procedures ?
Result sets from stored procedures can be read almost as easily as from
tables.

Sanjiv.

"Russ" <tyu...@aol.com> wrote in message
news:eoQ%23ivHUDHA.298@forums-2-dub...

Russ

unread,
Jul 23, 2003, 10:09:27 AM7/23/03
to
Sanjiv,

Thank you for the respond.

Yes, I am trying generate numbers at runtime.
It's dynamically created view - that is why no primary key or identity
column.

There is can be huge number of rows in result set.

Further process operates (AVG, MIN, MAX, etc.) with groups of records in the
range from N to M - that is why I need row number. I do not think it is a
good idea bring this process to front end.

Application can be used against different RDBMS (ORACLE, DB2, Teradata,
etc.) and only MS SQL gives me these problem. I do not want to have
exclusive code (sp) for MS SQL ...

Thanks.

"Sanjiv Das [TeamSybase]" <No-Spam-SDa...@HotMail.Com> wrote in
message news:#pakspJUDHA.261@forums-2-dub...

Phil Kaufman

unread,
Jul 23, 2003, 10:51:21 AM7/23/03
to
Russ,

I think you are referring to whether SQL Server has an Oracle equivalent to
rownum. This might help you:

IDENTITY (Function)
Is used only in a SELECT statement with an INTO table clause to insert an
identity column into a new table.

Although similar, the IDENTITY function is not the IDENTITY property that is
used with CREATE TABLE and ALTER TABLE.

Syntax
IDENTITY ( data_type [ , seed , increment ] ) AS column_name


HTH

Phil

"Russ" <tyu...@aol.com> wrote in message

news:%23B2H0USUDHA.145@forums-2-dub...

Russ

unread,
Jul 23, 2003, 11:58:35 AM7/23/03
to
Yes, I was searching something like ORACLE's row_number() ...
I'll check out if dba allowed create the temp tables ...
It looks like temp table will be the less harmful solution.

Phil, thank you very much.

Sanjiv, thank you as well again.

"Phil Kaufman" <ph...@dbcsmartsoftware.com> wrote in message
news:ebQruqSUDHA.346@forums-2-dub...

0 new messages