check constraint

  • Hi all, I need help setting up a check constraint. When someone enters a machinenumber into tableA, it must exist in the machines table. So TableA.machinenumber must exist in tableB. I'm not sure if this could be done as a constraint, or if it needs to be a trigger? Thanks in advance for any help.

    Al

  • Use a foreign Key Constraint with a  NOT Null option on the column

    HTH

     

     


    * Noel

  • Sorry, I should have mentioned, I have a DTS package that drops and re-creates the machinestable, so if I have a FK constraint, won't I get an error when running my DTS when it tries to drop the table?

  • If you DROP and recreate the table Yes of course you will get the error but in that case you could DISABLE the Constraint do your stuff and Re enable it

    HTH

     


    * Noel

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply