473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

It's Me again!

26
Okay,
I have a table with a LONGTEXT field. Some records have 1000+ characters in the suspect field. Since it's a LONGTEXT field, i can't figure out how to set a no-dupe index on it.

I get duplicate records where the first 100 characters are the same. If the first 100 are the same, the entire record is the same. Guaranteed. I have a field that includes the first 50 chars, but sometimes they are the same. (fld 1 "James d. Smith" fld 2= "James d. Smith has deployed" or "James d. Smith has been promoted"

I would like to eliminate existing duplicates. My thought is to create a TEXT field with 100 length, use a query to copy the first 100 chars over to it for each record. THEN, copy the structure, make that field UNIQUE then copy the records over, thus eliminating the duplicates.

Anyone have any better ideas? anyone have any code that does this?
Sep 15 '08 #1
1 969
iburyak
1,017 Expert 512MB
Here is my little test to simulate what you have and remove duplicates. I worked with first 14 characters just to make it small.


Expand|Select|Wrap|Line Numbers
  1. 1. Create a table
  2. create table #a (name varchar(100))
  3. 2. Insert some records
  4. insert into #a values ('James d. Smith has deployed')
  5. insert into #a values ('James d. Smith has deployed')
  6. insert into #a values ('b James d. Smith')
  7. insert into #a values ('a James d. Smith has deployed')
  8. insert into #a values ('James d. Smith has deployed')
  9. insert into #a values ('James d. Smith has deployed')
  10. insert into #a values ('b James d. Smith')
  11. insert into #a values ('a James d. Smith has deployed')
  12.  
  13. 3. Run code: 
  14. set rowcount 1
  15.  
  16. select 1
  17. While @@Rowcount > 0
  18. BEGIN
  19. delete from #a where substring(name,1,14) = (select top 1 substring(name,1,14)
  20.                          from #a
  21.                          group by substring(name,1,14)
  22.                          having count(*) > 1)
  23. END
  24. set rowcount 0 
  25.  
  26. 4. Check result
  27. select * from #a order by 1 
Your result should be:

a James d. Smith has deployed
b James d. Smith
James d. Smith has deployed

Then you can add a column to the table with first 100 characters to be able to have unique records.

Good Luck.
Sep 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Phill Long | last post by:
this is the the code, now here is the final result.... I get one combo box and one tex box come up, but they are empty... DAMN!!! Any ideas on what Im doing wrong please.. Thanks Again <?php...
1
by: Elaine | last post by:
Thanks again, Chuck, for your clsReadTextFile!! I've been running some tests against a SOAP web service using Java and Axis to make the calls, receive the responses and log the output. I have...
16
by: junky_fellow | last post by:
According to Section A6.6 Pointers and Integers (k & R) " A pointer to one type may be converted to a pointer to another type. The resulting pointer may cause addressing exceptions if the...
5
by: Sagaert Johan | last post by:
hi I have the following problem: I have a C# application that uses an activeX . I installed the application and the NET 1.1 Runtimes on a clean pc When running the application i discover...
1
by: ]-[aTc]-[ | last post by:
How do I fire a private void myTabStrip_SelectedIndexChange(object sender, System.EventArgs e) to fire again? I have a post back to my if statment and i have this ... if(Request != null) {
4
by: ad | last post by:
I write a time-consuming process in a button's onclick event. Some user may press the button again when the process is excuting. How to avoid that?
1
by: Henri Schomäcker | last post by:
Hi folks, what I need is a kind of 2D-Array which should, in the end, represent a typical html-table and which should be sortable by column. I thought of an implementation, where an vector...
3
by: moumita | last post by:
I want to create a form and display multiple symbols on it.The problem is how do I create and store the symbols so that I can display one single symbol multiple number of times on the form without...
2
by: SM | last post by:
Hello, I've created this 'wonderful' function the embeds a youtube video in a specified div section using the Javascript DOM. Everything works OK... until I realize how bad the logical programming...
1
by: inferi9 | last post by:
hi, I am writing the Sudoku game code and it is just from 1 to 3 (NOT to 9 like the ususal one) when i did right it give me the win message but when i did it wrong it also give me the win message,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.