as long as your primary keys are numbers but can be done in the same manner if they are strings
<!--- get all primary keys first.... --->
<cfquery name="blah" datasource="blahblah">
select TableID from Table
</cfquery>
<!--- Then get a random list item from the selected ids --->
<cfset RandomID = ListGetAt(valuelist(blah.TableID), RandRange(1, blah.recordcount))>
<!--- now just delete all WHERE TableID <> #val(RandomID)# --->
<cfquery datasource="blahblah">
delete from Table where TableID <> #val(RandomID)#
</cfquery>
----- Original Message -----
From: Greg Morphis
To: CF-Talk
Sent: Monday, August 16, 2004 3:32 PM
Subject: Re: SQL Question
I think you'd probably have to have a temp table and save a record to it
and then delete out the entire original table and then insert the
single row back into the table from temp.
On Mon, 16 Aug 2004 15:19:39 -0400, Qasim Rasheed
<[EMAIL PROTECTED]> wrote:
> Hello
>
> I want to delete all records from a table except one (a random one).
> Is there a way to do it? I am using SQL Server
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

