Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Ensure Table has only one row Expand / Collapse
Author
Message
Posted Thursday, December 8, 2011 12:30 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, November 13, 2014 7:04 AM
Points: 9, Visits: 436
Comments posted to this topic are about the item Ensure Table has only one row
Post #1218411
Posted Thursday, December 8, 2011 8:16 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, October 18, 2013 6:12 AM
Points: 952, Visits: 552
Sometimes I want to keep a "history" of the different settings, or have more than one set depending on circumstances. In these cases, I use a "current" column (bit) to determine which row I should be using. Just for info.
Post #1218651
Posted Thursday, December 8, 2011 1:39 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:57 PM
Points: 1,764, Visits: 4,958
An alternate method to insure only one row (or 2, 3, ... rows) would be to simply define a unique key and check constraint on the table's ID column.

create table tempdb..foo
(
foo_id int not null primary key check (foo_id = 1)
);


Post #1218934
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse