---
title: "SQL Server 2000 constraint involving column on different table"  
description: "SQL Server 2000 constraint involving column on different table"  
author: "Anonymous User"  
published: 2013-05-04  
updated: 2013-05-04  
canonical: https://www.mindstick.com/forum/814/sql-server-2000-constraint-involving-column-on-different-table  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# SQL Server 2000 constraint involving column on different table

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!\
\
I would like a constraint on a [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) 2000 table column that is sort of a combination of a [foreign key](https://www.mindstick.com/blog/174/foreign-key-self-reference-constraint) and a [check constraint](https://www.mindstick.com/forum/156741/why-are-use-the-sql-check-constraint-in-the-database-at-table-creation). The value of my column must exist \
\
in the other table, but I am only concerned with [values](https://www.mindstick.com/forum/327/sum-textbox-values) in the other table where one of its columns equal a specified value. The simplified tables are:\
\
import_table:\
part_number [varchar](https://www.mindstick.com/forum/161878/what-is-the-difference-between-nvarchar-and-varchar)(30)\
quantity int\
\
inventory_master:\
part_number varchar(30)\
type char(1)\
So I want to ensure the part_number exists in inventory_master, but only if the type is 'C'. Is this possible? Thanks.\
\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi John!\
You could use an INSTEAD OF INSERT trigger to emulate that behaviour.\
Check value existence when an insert is about to occur.


---

Original Source: https://www.mindstick.com/forum/814/sql-server-2000-constraint-involving-column-on-different-table

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
