renumerar registros | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

renumerar registros

Tengo una tabla con mas de 50000 registros y ahora fue necesario agregar un campo nuevo llamado ‘id_x’ en el cual debo colocar una numeración consecutiva de iniciando en 1, luego 2,3,4,5,6,… y así sucesivamente hasta el ultimo registro disponible. ¿Alguna solución que pudieran darme? Gracias de antemano.
Antonio Arciga
Fijate en la función IDENTITY en los libros en línea.
Luis Martin
Moderator
SQL-Server-Performance.com Although nature commences with reason and ends in experience it is necessary for us to do the opposite, that is to commence with experience and from this to proceed to investigate the reason.
Leonardo Da Vinci Nunca esperes el reconocimiento de tus hijos, eso ocurrirá luego de tu muerte
All postings are provided “AS IS” with no warranties for accuracy.
Gracias por responder. Fijate que llevo 2 días buscado en los libros en línea y no ecuentro una solución.

el tema luis que si le pone identity es un numero unico pero muy grande no un numero simple de 1 a n Me parece que tendria que haber otra forma. un query con un cursor para que cargue esto? No se escucho tu opinion ya que yo no tube que hacer nunca esto! ja
The Pipo Dba.
La verdad es que me perdí la respuesta de Antonio. Ahora segun BOL: IDENTITY Property
Identifier columns can be implemented using the IDENTITY property, which allows the application developer to specify both an identity number for the first row inserted into the table (Identity Seed property) and an increment (Identity Increment property) to be added to the seed to determine successive identity numbers. When inserting values into a table with an identifier column, Microsoft® SQL Server™ 2000 automatically generates the next identity value by adding the increment to the seed. When you use the IDENTITY property to define an identifier column, consider that: A table can have only one column defined with the IDENTITY property, and that column must be defined using the decimal, int, numeric, smallint, bigint, or tinyint data type.
The seed and increment can be specified. The default value for both is 1.
The identifier column must not allow null values and must not contain a DEFAULT definition or object.
The column can be referenced in a select list by using the IDENTITYCOL keyword after the IDENTITY property has been set.
The OBJECTPROPERTY function can be used to determine if a table has an IDENTITY column, and the COLUMNPROPERTY function can be used to determine the name of the IDENTITY column.
Luis Martin
Moderator
SQL-Server-Performance.com Although nature commences with reason and ends in experience it is necessary for us to do the opposite, that is to commence with experience and from this to proceed to investigate the reason.
Leonardo Da Vinci Nunca esperes el reconocimiento de tus hijos, eso ocurrirá luego de tu muerte
All postings are provided “AS IS” with no warranties for accuracy.
]]>