Home All Groups Group Topic Archive Search About

How start identity field at 100

Author
6 Nov 2007 3:47 PM
Cirene
I have a table with the PK field defined as an identity field with the
increment of 1.  How do I START the calculations at 100, rather than 1?

Author
6 Nov 2007 4:31 PM
William (Bill) Vaughn
When the table is first created, use an IdentitySeed value of 100.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
Show quote
"Cirene" <t***@test.com> wrote in message
news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>I have a table with the PK field defined as an identity field with the
>increment of 1.  How do I START the calculations at 100, rather than 1?
>
Author
6 Nov 2007 4:47 PM
Cirene
What if the rows already exist?  There are 3 rows that i don't want to
recreate, but it won't let me manually change the PK field.  Any ideas?
Thanks!

Show quote
"William (Bill) Vaughn" <billvaRemoveT***@betav.com> wrote in message
news:2DBCD4E7-75BD-4BAD-930B-574B3BD46A3F@microsoft.com...
> When the table is first created, use an IdentitySeed value of 100.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> INETA Speaker
> www.betav.com/blog/billva
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
> Visit www.hitchhikerguides.net to get more information on my latest book:
> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
> -----------------------------------------------------------------------------------------------------------------------
> "Cirene" <t***@test.com> wrote in message
> news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>>I have a table with the PK field defined as an identity field with the
>>increment of 1.  How do I START the calculations at 100, rather than 1?
>>
>
Author
6 Nov 2007 7:09 PM
Cor Ligthert[MVP]
You can try to remove temporaly the autoident setting of the key.

Cor
Author
8 Nov 2007 6:37 PM
William Vaughn
Setting the Identity column properties like Seed and AutoIncrement should
only be done on an empty table--not when tables already exist. It's rarely a
good idea to change the PK anyway.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

Show quote
"Cirene" <t***@test.com> wrote in message
news:OlvnQTJIIHA.4476@TK2MSFTNGP06.phx.gbl...
> What if the rows already exist?  There are 3 rows that i don't want to
> recreate, but it won't let me manually change the PK field.  Any ideas?
> Thanks!
>
> "William (Bill) Vaughn" <billvaRemoveT***@betav.com> wrote in message
> news:2DBCD4E7-75BD-4BAD-930B-574B3BD46A3F@microsoft.com...
>> When the table is first created, use an IdentitySeed value of 100.
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> INETA Speaker
>> www.betav.com/blog/billva
>> www.betav.com
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> __________________________________
>> Visit www.hitchhikerguides.net to get more information on my latest book:
>> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
>> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
>> -----------------------------------------------------------------------------------------------------------------------
>> "Cirene" <t***@test.com> wrote in message
>> news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>>>I have a table with the PK field defined as an identity field with the
>>>increment of 1.  How do I START the calculations at 100, rather than 1?
>>>
>>
>
>
Author
8 Nov 2007 6:51 PM
Cor Ligthert[MVP]
Bill,

> Setting the Identity column properties like Seed and AutoIncrement should
> only be done on an empty table--not when tables already exist. It's rarely
> a good idea to change the PK anyway.

I did it yesterday with a corrupted datatable from an SQL server 2000, which
was corrupt because that there was no primary key and was handled using SQL
Management Studio (it was not me who did it, so I am not sure what exactly
was the reason).

I could only do it with the SQL Enterprise tools. However it did help me a
lot.

Therefore never say never.

:-)

Cor

Show quote
"William Vaughn" <billvaNoSPAM@betav.com> schreef in bericht
news:elJU7ZjIIHA.4592@TK2MSFTNGP02.phx.gbl...
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant, Dad, Grandpa
> Microsoft MVP
> INETA Speaker
> www.betav.com
> www.betav.com/blog/billva
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
> Visit www.hitchhikerguides.net to get more information on my latest book:
> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
> -----------------------------------------------------------------------------------------------------------------------
>
> "Cirene" <t***@test.com> wrote in message
> news:OlvnQTJIIHA.4476@TK2MSFTNGP06.phx.gbl...
>> What if the rows already exist?  There are 3 rows that i don't want to
>> recreate, but it won't let me manually change the PK field.  Any ideas?
>> Thanks!
>>
>> "William (Bill) Vaughn" <billvaRemoveT***@betav.com> wrote in message
>> news:2DBCD4E7-75BD-4BAD-930B-574B3BD46A3F@microsoft.com...
>>> When the table is first created, use an IdentitySeed value of 100.
>>>
>>> --
>>> ____________________________________
>>> William (Bill) Vaughn
>>> Author, Mentor, Consultant
>>> Microsoft MVP
>>> INETA Speaker
>>> www.betav.com/blog/billva
>>> www.betav.com
>>> Please reply only to the newsgroup so that others can benefit.
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>> __________________________________
>>> Visit www.hitchhikerguides.net to get more information on my latest
>>> book:
>>> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
>>> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
>>> -----------------------------------------------------------------------------------------------------------------------
>>> "Cirene" <t***@test.com> wrote in message
>>> news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>>>>I have a table with the PK field defined as an identity field with the
>>>>increment of 1.  How do I START the calculations at 100, rather than 1?
>>>>
>>>
>>
>>
>
Author
6 Nov 2007 4:36 PM
Cowboy (Gregory A. Beamer)
Set the seed to 100. If you are using the SQL Manager, you can alter there,
but be careful with live databases using this method.

With scripting, the method is:

CREATE TABLE TableWithIdentityColumn
(
    MyID    int    IDENTITY(100,1) PRIMARY KEY
    , SomeData varchar(2000) NOT NULL
)

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
Show quote
| Think outside the box!
|
*************************************************
"Cirene" <t***@test.com> wrote in message
news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>I have a table with the PK field defined as an identity field with the
>increment of 1.  How do I START the calculations at 100, rather than 1?
>
Author
6 Nov 2007 4:44 PM
Norman Yuan
If it is Identity column, why do you care what its value is?


Show quote
"Cirene" <t***@test.com> wrote in message
news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>I have a table with the PK field defined as an identity field with the
>increment of 1.  How do I START the calculations at 100, rather than 1?
>
Author
6 Nov 2007 5:08 PM
Cirene
i display it to the user as the id for the home listing

Show quote
"Norman Yuan" <NoAddr***@NoEmail.fake> wrote in message
news:uyJTJSJIIHA.868@TK2MSFTNGP05.phx.gbl...
> If it is Identity column, why do you care what its value is?
>
>
> "Cirene" <t***@test.com> wrote in message
> news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>>I have a table with the PK field defined as an identity field with the
>>increment of 1.  How do I START the calculations at 100, rather than 1?
>>
>
Author
6 Nov 2007 11:17 PM
Norman Yuan
The only purpose for Identity is to give a unique number. Even you can
managed to make it starts from 100, is it still OK if next number is 103,
not 101 (if 2 records have been added mistakenly and then deleted)? If it is
OK, then I do not see why you have to waste time to get the SQL Server to
start an ID from 100 Or any other arbitatry number). If it is not OK, then
you should not use Identity column at all.


Show quote
"Cirene" <t***@test.com> wrote in message
news:esV6EfJIIHA.4196@TK2MSFTNGP04.phx.gbl...
>i display it to the user as the id for the home listing
>
> "Norman Yuan" <NoAddr***@NoEmail.fake> wrote in message
> news:uyJTJSJIIHA.868@TK2MSFTNGP05.phx.gbl...
>> If it is Identity column, why do you care what its value is?
>>
>>
>> "Cirene" <t***@test.com> wrote in message
>> news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>>>I have a table with the PK field defined as an identity field with the
>>>increment of 1.  How do I START the calculations at 100, rather than 1?
>>>
>>
>
>
Author
6 Nov 2007 11:39 PM
Cirene
It is ok as long as it starts at 100 and above.  I guess I need to tweak the
design.  Thanks!

Show quote
"Norman Yuan" <NoAddr***@NoEmail.fake> wrote in message
news:eeNm2tMIIHA.4880@TK2MSFTNGP03.phx.gbl...
> The only purpose for Identity is to give a unique number. Even you can
> managed to make it starts from 100, is it still OK if next number is 103,
> not 101 (if 2 records have been added mistakenly and then deleted)? If it
> is OK, then I do not see why you have to waste time to get the SQL Server
> to start an ID from 100 Or any other arbitatry number). If it is not OK,
> then you should not use Identity column at all.
>
>
> "Cirene" <t***@test.com> wrote in message
> news:esV6EfJIIHA.4196@TK2MSFTNGP04.phx.gbl...
>>i display it to the user as the id for the home listing
>>
>> "Norman Yuan" <NoAddr***@NoEmail.fake> wrote in message
>> news:uyJTJSJIIHA.868@TK2MSFTNGP05.phx.gbl...
>>> If it is Identity column, why do you care what its value is?
>>>
>>>
>>> "Cirene" <t***@test.com> wrote in message
>>> news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>>>>I have a table with the PK field defined as an identity field with the
>>>>increment of 1.  How do I START the calculations at 100, rather than 1?
>>>>
>>>
>>
>>
>
Author
7 Nov 2007 6:20 AM
Andrew Faust
Don't worry about what Cirene is saying. It's OK to display an identity
column to your users. Some people choose not to do so, but it's more about
design differences than anything else. I don't agree with pushing this
functionality up to the app level merely to "not waste the DB's time". Odds
are you are going to use an identity column to link tables anyway. You may
as well use it for an ID in the app rather than waste your time building
more code.

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com


Show quote
"Cirene" <t***@test.com> wrote in message
news:eY8$c5MIIHA.6068@TK2MSFTNGP05.phx.gbl...
> It is ok as long as it starts at 100 and above.  I guess I need to tweak
> the design.  Thanks!
>
> "Norman Yuan" <NoAddr***@NoEmail.fake> wrote in message
> news:eeNm2tMIIHA.4880@TK2MSFTNGP03.phx.gbl...
>> The only purpose for Identity is to give a unique number. Even you can
>> managed to make it starts from 100, is it still OK if next number is
>> 103, not 101 (if 2 records have been added mistakenly and then deleted)?
>> If it is OK, then I do not see why you have to waste time to get the SQL
>> Server to start an ID from 100 Or any other arbitatry number). If it is
>> not OK, then you should not use Identity column at all.
>>
>>
>> "Cirene" <t***@test.com> wrote in message
>> news:esV6EfJIIHA.4196@TK2MSFTNGP04.phx.gbl...
>>>i display it to the user as the id for the home listing
>>>
>>> "Norman Yuan" <NoAddr***@NoEmail.fake> wrote in message
>>> news:uyJTJSJIIHA.868@TK2MSFTNGP05.phx.gbl...
>>>> If it is Identity column, why do you care what its value is?
>>>>
>>>>
>>>> "Cirene" <t***@test.com> wrote in message
>>>> news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>>>>>I have a table with the PK field defined as an identity field with the
>>>>>increment of 1.  How do I START the calculations at 100, rather than
>>>>>1?
>>>>>
>>>>
>>>
>>>
>>
>
>
Author
7 Nov 2007 7:14 AM
Cirene
Thanks!

Show quote
"Andrew Faust" <and***@andrewfaust.com> wrote in message
news:A63D2FAE-21EF-4704-90B3-554F3309B9C6@microsoft.com...
> Don't worry about what Cirene is saying. It's OK to display an identity
> column to your users. Some people choose not to do so, but it's more about
> design differences than anything else. I don't agree with pushing this
> functionality up to the app level merely to "not waste the DB's time".
> Odds are you are going to use an identity column to link tables anyway.
> You may as well use it for an ID in the app rather than waste your time
> building more code.
>
> --
> Andrew Faust
> andrew[at]andrewfaust.com
> http://www.andrewfaust.com
>
>
> "Cirene" <t***@test.com> wrote in message
> news:eY8$c5MIIHA.6068@TK2MSFTNGP05.phx.gbl...
>> It is ok as long as it starts at 100 and above.  I guess I need to tweak
>> the design.  Thanks!
>>
>> "Norman Yuan" <NoAddr***@NoEmail.fake> wrote in message
>> news:eeNm2tMIIHA.4880@TK2MSFTNGP03.phx.gbl...
>>> The only purpose for Identity is to give a unique number. Even you can
>>> managed to make it starts from 100, is it still OK if next number is
>>> 103, not 101 (if 2 records have been added mistakenly and then deleted)?
>>> If it is OK, then I do not see why you have to waste time to get the SQL
>>> Server to start an ID from 100 Or any other arbitatry number). If it is
>>> not OK, then you should not use Identity column at all.
>>>
>>>
>>> "Cirene" <t***@test.com> wrote in message
>>> news:esV6EfJIIHA.4196@TK2MSFTNGP04.phx.gbl...
>>>>i display it to the user as the id for the home listing
>>>>
>>>> "Norman Yuan" <NoAddr***@NoEmail.fake> wrote in message
>>>> news:uyJTJSJIIHA.868@TK2MSFTNGP05.phx.gbl...
>>>>> If it is Identity column, why do you care what its value is?
>>>>>
>>>>>
>>>>> "Cirene" <t***@test.com> wrote in message
>>>>> news:e3mKixIIIHA.5328@TK2MSFTNGP05.phx.gbl...
>>>>>>I have a table with the PK field defined as an identity field with the
>>>>>>increment of 1.  How do I START the calculations at 100, rather than
>>>>>>1?
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>

AddThis Social Bookmark Button