sql server - Delete repeating data C# to SQL conversion -
I need to delete the repetitive user information from the database. My c # code is below, but I'm surprised How to get it in SQL without using the cursor I think the trick starts by getting the remaining rows of dashed datasets individually by the first rows or email.
In C #, I repeat the email by group of 1000 and leave the remaining rows first one.
list & lt; String & gt; Top1000_emails; Do {top1000_emails = sql.dbCommand.GetFirstColumn & lt; String & gt; (@ "Select Top 1000 Emails with e-mail from userbusiness group" (e-mail)> 1); (EnterI = 0; I & lt; Top -1000_Email.Count; I ++) {var tmpids = sql.dbCommand.GetFirstColumn & lt; Long & gt; ("Choose from the userbase [id] where email = {0}", top 1000_mail [ii]). (1) Go; Sql.dbCommand.DeleteByIds & LT; Usbase & gt; (Tmpids); }} While (top1000_emails.Count> gt; 0); You can do this easily through SIL, such as (if you have SQL Server 2005) or higher): ; Together (Selection *, ROW_NUMBER ()) (user Rowman per line of e-mail order) - Removed rows will be: SELECT * --DELETE from where a.RowNum & lt; & Gt; 1
Comments
Post a Comment