Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit Number of Records In Table Based on Column Value

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
Is there a way to limit the number of records in a table for a value of one of the columns?
Say I have a column named BoxID.
I want to limit the number of records in this table that have BoxID = 'ABC' to 2 records.
You could think of this as an Invoice Detail table where I don't want there to be more than 2 records with BoxID of 'ABC'
Would something like this work?
Insert into Table ... Where (Select Count(1) From Table Where BoxID = 'ABC' Group By BoxID) < 2
Is there another approach?

Auguy
Sylvania/Toledo Ohio
 
Sorry, posted in wrong forum
Will re-post in correct forum


Auguy
Sylvania/Toledo Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top