RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums

help with an sql statement

Join Date: Jan 2008
Location: Largo Florida
Posts: 448
Reputation: serkansendur is on a distinguished road 
Rep Power: 1
Solved Threads: 32
serkansendur's Avatar
serkansendur serkansendur is offline Offline
Posting Pro in Training

Re: help with an sql statement

  #11  
Jan 31st, 2008
your final sql will be as follows :

this code below deletes only first found row of row sets having the same value for the column nvarchar1 and the value of 1 for the column int1

declare @varchar1 nvarchar(50)
declare mycursor cursor for
select varchar1,
from mytable
group by varchar1
having count(*) > 1

open mycursor

FETCH NEXT FROM mycursor INTO @varchar1
WHILE @@FETCH_STATUS = 0
begin

delete top (1) from mytable where (@varchar1=varchar1 and int1=1)
FETCH NEXT FROM mycursor INTO @varchar1
end

close mycursor
deallocate mycursor
Serkan Şendur
MCAD.NET
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 7:25 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC