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] "Martin Bl." <guest@discussions.microsoft.com> wrote in message news:%23Aiz22SAIHA.4836@TK2MSFTNGP06.phx.gbl... > 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 >
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
Thanks! That was fast! :-) [quoted text, click to view] "Russell Fields" <russellfields@nomail.com> wrote in message news:udf6H%23SAIHA.748@TK2MSFTNGP04.phx.gbl... > 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 > > "Martin Bl." <guest@discussions.microsoft.com> wrote in message > news:%23Aiz22SAIHA.4836@TK2MSFTNGP06.phx.gbl... >> 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 >> > >
Thanks! That was fast! :-) [quoted text, click to view] "Russell Fields" <russellfields@nomail.com> wrote in message news:udf6H%23SAIHA.748@TK2MSFTNGP04.phx.gbl... > 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 > > "Martin Bl." <guest@discussions.microsoft.com> wrote in message > news:%23Aiz22SAIHA.4836@TK2MSFTNGP06.phx.gbl... >> 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 >> > >
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] "Russell Fields" <russellfields@nomail.com> wrote in message news:udf6H%23SAIHA.748@TK2MSFTNGP04.phx.gbl... > 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 > > "Martin Bl." <guest@discussions.microsoft.com> wrote in message > news:%23Aiz22SAIHA.4836@TK2MSFTNGP06.phx.gbl... >> 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 >> > >
[quoted text, click to view] > 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"
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] "Martin Bl." <guest@discussions.microsoft.com> wrote in message news:upPiLNTAIHA.1168@TK2MSFTNGP02.phx.gbl... > 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? > > "Russell Fields" <russellfields@nomail.com> wrote in message > news:udf6H%23SAIHA.748@TK2MSFTNGP04.phx.gbl... >> 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 >> >> "Martin Bl." <guest@discussions.microsoft.com> wrote in message >> news:%23Aiz22SAIHA.4836@TK2MSFTNGP06.phx.gbl... >>> 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 >>> >> >> > >
Don't see what you're looking for? Try a search.
|