Dedupe SQL

Hi

Im trying to dedupe my SQL 7 DB from my SQl statemnt

Im currently using teh following :

var SQL = "SELECT DISTINCT ref1 FROM tbl1

but beacse some of my fields are NTEXT I cannot request all the filds i wish to display ??

Is this the nest way to dedupe with SQL ??

Thanks
IT



itimesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saqib KhanSenior DeveloperCommented:
Maybe Try this..

var SQL = "SELECT DISTINCT ref1, Convert(nvarchar(10000), ref2) FROM tbl1

where ref2 is nText
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
itimesAuthor Commented:
adilkhan,

Ok teh covert seems to work after i reduced teh size down to 4000 as it says this is teh max but i now get

"ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal. "

What is the RS name for ref2 now ???
0
itimesAuthor Commented:
Sorry just added the " as ref2 " line .... works now ....

so its still doing teh dedupe but converting the NTEXT into a compatable N#nvarchar ... is teh "convert" just part of SQL then ???
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

itimesAuthor Commented:
adilkhan ,

I spke too soon there are no errors but it seems to ignore the DISTINCT clause as im stil getting duplicated records with teh same ref1 values ...... ??

Help !!!
0
Saqib KhanSenior DeveloperCommented:
reason why you getting duplicates is because maybe second column does not have 100% Same data for all the other distinct Rows.

1 hello
1 hello.

Not Distinct.

0
Saqib KhanSenior DeveloperCommented:
Distinct keyword will work fine As long as the ROWS specified int he Select Statement are matching, if 1 ROW has different values for 1 Column then other and appears twice then its not Distinct.

Converts change the DataType Dynamicly on the Fly for SQL statement. yes its T-SQL keyword.
0
itimesAuthor Commented:
adilkhan,

Your right the "second column does not have 100% Same data" so how cani dedupe on teh first coleum but still diaplsy all teh recordset info for each record found ???

Sorry about the dealy in getting back to you ...

Thanks

IT
0
Saqib KhanSenior DeveloperCommented:
if you think about it, its not possible. You can do a Group by and Show the Count of Other Columns.


var SQL = "SELECT ref1, Count(Convert(nvarchar(10000), ref2)) FROM tbl1 Group By ref1"
0
itimesAuthor Commented:
adilkhan,

Thansk for teh feedback...

Im looking at droping teh recordset into an arrya and then deduping that array, that way iv got more control of what i see aftre teh dedupe and its still fast.

Thanks

IT
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.