Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 delete query for sql server 2000

Author  Topic 

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-08-28 : 01:40:12
hi delete query required in sql server 200o as it works fine with 2005.

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-28 : 02:04:55
what is the primary key of the table ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-08-28 : 02:15:19
problem_id
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-08-28 : 02:42:07
thanks i got it

DELETE
FROM emrpatientproblems_bak
WHERE problem_id NOT IN
(
SELECT MAX(problem_id)
FROM emrpatientproblems_bak
GROUP BY problem_code,patient_id)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-28 : 02:43:52
Thank you for the feedback.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -