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, February 26, 2015 1:13 PM
Points: 9, Visits: 446
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: Monday, February 2, 2015 9:35 AM
Points: 952, Visits: 553
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


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 10:13 AM
Points: 2,439, Visits: 6,173
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)
);





Opening the small mailbox reveals a leaflet.

> read leaflet

"ZORK is a game of adventure, danger, and low cunning. In it you will explore some of the most amazing territory ever seen by mortals."
http://www.web-adventures.org/cgi-bin/webfrotz?s=Zork1
Post #1218934
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse