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 08, 2011 12:30 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 21, 2013 9:08 AM
Points: 6, Visits: 397
Comments posted to this topic are about the item Ensure Table has only one row
Post #1218411
Posted Thursday, December 08, 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: Tuesday, May 21, 2013 6:22 AM
Points: 805, Visits: 538
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 08, 2011 1:39 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:21 AM
Points: 1,164, Visits: 3,340
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)
);





"Wise people understand the 10,000 things without going to each one.
They know them without having to look at each one,
and they transform all without acting on each one." - The Tao Te Ching: Verse 47
Post #1218934
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse