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.
| Author |
Topic |
|
RichardSteele
Posting Yak Master
160 Posts |
Posted - 2003-06-13 : 03:02:39
|
| I have duplicate records that include ntext datatypes. I need to export only the unique records. Exporting using a query, Select DISTINCT * from tablename, doesn't work with text datatypes.What is the best way to accomplish this? Thanks in advance! |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-06-13 : 10:14:38
|
| Easiest way I can think of is to convert the text to a large varchar .... are they mostly <= 8000 characters? or, if there is a difference, will it be in the first 8000 characters?if either is YES, then you can use GROUP BY.if the key of the table is ID, then something like this should select only distinct rows (note that the entire text column is returned, not just the varchar() conversion):select a.*FROMYourTable aINNER JOIN (select Min(ID) as MinID FROM YourTable GROUP BY f1, f2, f3, f4 ... , convert(varchar(8000), TextField)) bONA.ID = B.MinIDIf there is no key to your table, then good luck to you !- Jeff |
 |
|
|
|
|
|