Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 limiting identities

Author  Topic 

detlion1643
Yak Posting Veteran

67 Posts

Posted - 2010-06-05 : 13:21:25
I am creating a database for a new inventory system I am setting up. The company wants 2 different tables for inventory (different categories). I kind of want all inventory ids to be primary across the tables. Is there a way to say, limit or start the int datatype set up with the tables? Table1 will uses ids from 1-100000000 and table 2 from 1000000001 and up.

malpashaa
Constraint Violating Yak Guru

264 Posts

Posted - 2010-06-05 : 14:16:14
Use CHECK constraint like this:

--Table1 constraint
CONSTRAINT Table1_CHECK_id CHECK(id BETWEEN 1 AND 100000000)

--Table2 constraint
CONSTRAINT Table2_CHECK_id CHECK(id > 100000000)
Go to Top of Page
   

- Advertisement -