Microsoft
Software
Hardware
Network
Question : Need to turn a SQL select into a delete statement
I have the following SQL statement that I need to turn into a delete
SELECT update_id,DTTM_IMPORTED FROM PS_MAINTENANCE_LOG
GROUP BY update_id,DTTM_IMPORTED
HAVING Count(*) > 1
--- This was submitted but it did not leave one of the duplicate rows, it deleted all rows where the count(*) was greater than one.
delete from ps_maintenance_log
where (update_id,DTTM_IMPORTED) in
(
SELECT update_id,DTTM_IMPORTED FROM PS_MAINTENANCE_LOG
GROUP BY update_id,DTTM_IMPORTED
HAVING Count(*) > 1
)
Thanks in advance.
Answer : Need to turn a SQL select into a delete statement
can you try the below :
delete from ps_maintenance_log x
where exists ( select 1 from ps_maintenance_log y
where x.update_id = y.update_id
and x.DTTM_IMPORTED = y.DTTM_IMPORTED
and x.rowid < y.rowid );
Thanks
Random Solutions
override err.raise?
Excel 2003 Toolbar is different than Excel 2007 toolbar
Loop through Months Of Year to pop ddl
Sharepoint Survey: Clicked 'No' to 'Show user names while creating the survey! Is there a way to turn the feature back on to see the names again?
run excel and run the enable auto refresh
TS users access maping folders in windows 2008 slow
Syntax for Sharepoint Outgoing "From Email" to display name + email address
Access: 'Control can't be edited - bound to unknown field'
windows 7 home password policy
WHat is the recommended size for the swapfile for my SQL Server ?