Viewing 11 posts - 1 through 11 (of 11 total)
I know just enough about this to be dangerous...so I have a basic question.
One of the posters (GSquared) offered this method:
select 1;
while @@rowcount > 0
delete top (1000)
from table
where x= y;
Is...
February 18, 2011 at 7:12 am
Disregard this question... I think it may have been my script 'feeder' program.
September 10, 2009 at 5:06 pm
Thanks everyone.
I used benyos' reply to work out a solution and was testing it when drew.allen responded. My query looks like drew.allen's and appears to work.
The part that I...
September 1, 2009 at 10:35 am
OK - Here's the question once again with, hopefully, a format that follows the forum etiquette.
The goal is to update the destination table with only the most recent record in...
August 31, 2009 at 9:00 am
Thanks, that works. I'll need to read up on OPENXML
August 21, 2009 at 1:34 pm
That does it!
I was trying something similar but couldn't quite get it. I think I was using a subquery after the inner join...
Thanks.
July 14, 2009 at 4:05 pm
Table and data:
CREATE TABLE [dbo].[tblArchiveRecords](
[SequenceID] [bigint] IDENTITY(-9223372036854775808,1) NOT NULL,
[ArchiveID] [int] NOT NULL
)
CREATE TABLE [dbo].[tblPublishPosition](
[SequenceID] [int] IDENTITY(1,1) NOT NULL,
[ArchiveID] [int] NOT NULL,
[PublishedPosition] [bigint] NOT NULL
)
insert into [dbo].[tblArchiveRecords] (ArchiveID) values (1)
insert into...
July 14, 2009 at 3:39 pm
I changed the query to
DELETE MyTable FROM
(SELECT IdentityColumn,DENSE_RANK() OVER(PARTITION BY ObjectId,DataKey ORDER BY IdentityColumn DESC) 'Rank'
FROM MyTable) MyTable1
WHERE MyTable.IdentityColumn = MyTable1.IdentityColumn
AND MyTable1.Rank > 1
and that appears to...
July 1, 2009 at 7:05 am
Thanks Pandian,
I tried that query...it appears that it doesn't leave the record with the greatest identity value and remove the rest. I think the lowest identity value was the one...
July 1, 2009 at 6:58 am
OK, I think I've got it.
In my test to show the records that would be deleted, I ran only the select subquery:
select * from MyTable t
where t.ObjectId=MyTable.ObjectId
and t.DataKey=MyTable.DataKey
and t.IdentCol>MyTable.IdentCol
I didn't...
June 30, 2009 at 10:22 am
Thanks Mark,
I'm a newbie with SQL, so forgive the ignorance. I don't really understand why that query works. I ran just the 'select' portion to see if it returned...
June 30, 2009 at 10:08 am
Viewing 11 posts - 1 through 11 (of 11 total)