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.
| Author |
Topic |
|
skiabox
Posting Yak Master
169 Posts |
Posted - 2008-10-29 : 05:53:03
|
| How can I set a primary key of a table to be able to take values only from a specific range of values (for example [-2, -1, 0, 1, 2, 3]).Thank you very much. |
|
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2008-10-29 : 05:56:18
|
| A CHECK constraint is used to limit the values that can be placed in a column. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 06:04:07
|
| see examples herehttp://doc.ddart.net/mssql/sql70/create_7.htm |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-10-29 : 08:07:33
|
| Of course you can also have your PK as an FK into another table of allowable values. It just depends on the scale of it and how flexible you need to be. |
 |
|
|
ursangel
Starting Member
17 Posts |
Posted - 2008-10-29 : 11:36:19
|
| You can propably choose to have a Check constarint or a foreignkey to a pre defined table.I would suggest the second one, as your values are predefined and is not in a range.RegardsAngel |
 |
|
|
|
|
|