dbTalk Databases Forums  

Is there a way to have an dynamic identity column?

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss Is there a way to have an dynamic identity column? in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ThunderMusic
 
Posts: n/a

Default Is there a way to have an dynamic identity column? - 03-29-2007 , 09:08 AM






Hi,
What I want to do is a Select on a table that adds a dynamic column like
let's say Select T.*, GetDate() From MyTable T; My example is not very
useful, but it's just so you get the point... Now, I want the select to
create a simili-identity column that will set an incrementing value to each
record so I can filter afterward like this :

Select T.*, <IdentityFunction> as id From MyTable T Where id between @min
and @max ORDER BY MyColumn;

The goal to this is to create a query for a data list with a page so I don't
have to skip records in order to obtain the ones I need... I Would like to
select only the ones I need...

Is it possible?

Thanks



Reply With Quote
  #2  
Old   
Andrew J. Kelly
 
Posts: n/a

Default Re: Is there a way to have an dynamic identity column? - 03-29-2007 , 12:00 PM






What version are you using? There are plenty of examples available on
paging like this that you can find from a simple google search. If you are
using SQl2005 then have a looka t the ROW_ID() function.

--
Andrew J. Kelly SQL MVP

"ThunderMusic" <NoSpAmdanlatathotmaildotcom (AT) NoSpAm (DOT) com> wrote

Quote:
Hi,
What I want to do is a Select on a table that adds a dynamic column like
let's say Select T.*, GetDate() From MyTable T; My example is not very
useful, but it's just so you get the point... Now, I want the select to
create a simili-identity column that will set an incrementing value to
each record so I can filter afterward like this :

Select T.*, <IdentityFunction> as id From MyTable T Where id between @min
and @max ORDER BY MyColumn;

The goal to this is to create a query for a data list with a page so I
don't have to skip records in order to obtain the ones I need... I Would
like to select only the ones I need...

Is it possible?

Thanks




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.