August 27, 2009 at 11:36 pm
hi my delete query is working fine qith sql server 2005.please help me out giving query in sql server 2000.
DELETE D
FROM
(
SELECT *
,ROW_NUMBER() OVER (PARTITION BY problem_code, patient_id ORDER BY PROBLEM_ID DESC) AS RowNum
FROM EMRPATIENTPROBLEMS
) D
WHERE RowNum > 1
GO
August 31, 2009 at 6:50 am
[font="Verdana"]It seems that you are trying to delete duplicate records. What you have to do is to write a query in SQL Server 2K to return the duplicate records using HAVING clause and then delete those records.
Let us know on this,
Mahesh[/font]
MH-09-AM-8694
August 31, 2009 at 7:26 am
Check the below article out. It gives a nice explanation along with SQL 2000 and 2005 syntax and query idea's.
http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=DuplicateRows
Thanks,
S
--
:hehe:
September 1, 2009 at 5:57 am
You can do a select distinct and insert the records in a new table , drop the old table and rename the new table to the original table. You can do this only if the table contains small or moderate amount of data. Make sure the new table contains all indexes, constraints etc.
"Keep Trying"
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply