Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISTINCT QUESTION

Status
Not open for further replies.

makisbest

Technical User
Mar 3, 2005
125
GR
Dar Friends

Why when I put the DISTINCT statement in my SQL query the VB6 return me an error.
In my SQL Query Analyzer just work fine.

strsql = "SELECT DISTINCT * FROM DOCHDSAL, LITMSALE”

It is Service Pack Problem ?
 
Run-time error '-2147217900 (80040e14)':

The text,ntext, or image data type cannot be selected as distinct
 
3 fields of integer and about 666 records. Without distinct returns about 1300 double records.

3,12,12
4,5,12
6,2,9
 
SQL Books on Line says <When querying, Microsoft® SQL Server™ does not allow the use of SELECT DISTINCT on a text, ntext, or image column.>

I guess that one of the fields included in your * collection falls into that category. You can get Books On Line as a download from:

Everyone who uses MSSQL or MSDE should have a copy to hand!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
I don't think you can do DISTINCT on multiple fields like that. Try DISTINCT fieldname. If you must use multiple fields concatenate them and then use DISTINCT on that.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hi,

Not sure if this will work but I tried it and worked for me.

SELECT DISTINCT(ID) As disID, Name, Amount FROM <table>

It would return DISTINCT IDS and the names and amounts that match it. Dont know if this will help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top