all groups > sql server programming > september 2007 >
You're in the

sql server programming

group:

Initialize Auto-Incremental, Unique field?


Re: Initialize Auto-Incremental, Unique field? Russell Fields
9/27/2007 1:55:00 PM
sql server programming: Martin,

If you look at the IDENTITY property you will see that it has a seed and
increment setting. So, you can set the starting number and whether it
increments by 1 or 3 or 11, etc.

CREATE TABLE MyTable (
AutoID INT IDENTITY (5001, 1),
Name NVARCHAR(100))

In addition, if you want to avoid anything ever being inserted below your
certain number, you could also add a CHECK CONSTRAINT to the column such as:
CHECK (AutoID > 5000)

RLF

[quoted text, click to view]

Initialize Auto-Incremental, Unique field? Martin Bl.
9/27/2007 7:40:26 PM
Hi!

I'm looking for a way to make sure that the value of a primary key,
unique-autoIncremental field in a table, will be above a certain number...
Is there a standard way to do that?

BTW
I wanted also to ask: Is it the standard that auto-incremental fields start
from 1?

Thanks a lot!
Martin

Re: Initialize Auto-Incremental, Unique field? Martin Bl.
9/27/2007 8:09:39 PM
Thanks! That was fast! :-)

[quoted text, click to view]

Re: Initialize Auto-Incremental, Unique field? Martin Bl.
9/27/2007 8:09:48 PM
Thanks! That was fast! :-)

[quoted text, click to view]


Re: Initialize Auto-Incremental, Unique field? Martin Bl.
9/27/2007 8:20:23 PM
Another one: I'm not using IDENTITY, it is a database engine that does not
understand it,
but i'm using "AutoID INT PRIMARY KEY AUTOINCREMENT UNIQUE", is there a good
way here also?

[quoted text, click to view]

Re: Initialize Auto-Incremental, Unique field? Tibor Karaszi
9/28/2007 12:00:00 AM
[quoted text, click to view]

This is a SQL Server forum. I suggest you ask the question in a forum for the DBMS that you are
using.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi


[quoted text, click to view]
AddThis Social Bookmark Button