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 |
Looper
Yak Posting Veteran
68 Posts |
Posted - 2009-01-30 : 05:21:31
|
I want to set up a default value on a integer field. The integer represents an identity id field in a reference table which provides a code. e.g. Ref Table Id 6 = Code X.I have the following constraint set up, however if the Ids in the reference table ever get out of sync then the constraint will be producing the wrong code. Is there anyway to say set the default value to the Id where code = X in the constraint? ALTER TABLE [dbo].[t_Employees] ADD CONSTRAINT [df_Emps_OrientationId] DEFAULT (6) FOR [OrientationId]GO |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-01-30 : 05:44:35
|
Not without using a trigger AFAIK. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-30 : 09:49:46
|
similarly for each code you need to put different value in int column?> |
|
|
|
|
|