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.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 Table Creation

Author  Topic 

al_gsy
Starting Member

6 Posts

Posted - 2005-12-20 : 04:16:44
Hi,

First time poster here, basically I have a second year university module on database design and for our coursework we have to model and create a database. One of the questions asks us to create a table that has a constraint on how many rows it can contain. I now that this is possible in some other databases, however I haven't seen a constraint that I could use on create table to limit the number of rows.. Does anyone now if this is possible?

Thanks,

Al

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-12-20 : 04:37:02
there's no such constraint that i know of.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2005-12-20 : 04:49:10
if you really need to limit no of records in a table, you can use insert tigger to achieve this.

-----------------
[KH]

Learn something new everyday
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-12-20 : 05:24:29
true
but i wouldn't use instead of triggers for this... i'd handle that in the app.
because i think that db shouldn't care about how many rows are in the table.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

al_gsy
Starting Member

6 Posts

Posted - 2005-12-20 : 06:47:08
Thanks for the feedback, I thought that the only way you may be able to do this was to create a trigger. I agree that it's a unlikely situation that you might want to restrict a table on row capacity, but the fact is that from an academic point of view it is possible as part of SQL's language specification, however not many DBMS' actually bother to implement it afaik.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-20 : 07:07:35
As said, use Your presentation layer to check the number of rows before trying to insert a Record. Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -