Hi,
There are two issues here.
(1) You can't use a ntext,text or image datatyped columns in a group by clause.
(2) If the datatype can be changed to nvarchar without affecting your application, then it is the best solution.
(3) But if the column has to be of ntext datatype, then you can try this.
Create on more column in the table which would be like an abbreviation for the data in ntext coulmn. So, this abbreviation represents the data in ntext column. Now you can use this abbreviation column in your group clause or distinct clause.
But you have to create a mechanism for creating the abbreviation while you input the data to database. Also if there is lot of data in the table, then you should also create a mechanism for upadting the abbreviation column.
Suppose the data in table is as follows:
Col1 Col2(ntext)
------ -----------
1 A..............
2 B..............
3 XYZ
4 XYZ
5 C......
Add a column of simple datatype probably varchar and update the data in Col3.
Col1 Col2(ntext) Col3(Col2 Abbreviation)
------ -----------
1 A............... ABBREVIATION_1
2 B............... ABBREVIATION_2
3 XYZ ABBREVIATION_3
4 XYZ ABBREVIATION_3
5 C...... ABBREVIATION_4
Now you can use Col3 in place of Col2 for using it in "Group By" clause or DISTINCT clause.
Hope this works.
Thanks,
Sreenivas
---------