Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Check constraint based on other tables

$
0
0
Hi, I have a number of tables each containing information about a different piece of machine tooling. Each piece of tooling has a tube diameter to indicate the size of tubing that it can be used for. I then have a table which allows combinations of the machine tooling to be entered by having columns which are the primary keys of the sub table. Something like the below. What I need is when a tool set record is inserted or updated to check that all the tube_diameters match. I believe that I can't reference other tables in the check constraint dialog of SQL server management studio but need to create a function to do the comparison and call the function from the check constraint. I am having a hard time getting my head around what the function would look like - how do I tell it which record in the tool set table I am interested in to know the numbers to look at in the sub-tables?Thanks in advance for any help !TOOL_SET:Tool_Set_NumberClamp_NumberFormer_NumberWiper_NumberClamp:Clamp_NumberTube_DiameterLengthHeightFormer:Former_NumberTube_DiameterCLRWiper:Wiper_NumberTube_DiameterLengthHeight

Viewing all articles
Browse latest Browse all 3145

Trending Articles