Solved

Sort ntext

Posted on 2004-08-25
5
498 Views
Last Modified: 2008-02-01
Hi,

I am using SQL CE 2.0 and have an ntext field which I need to sort.  Due to integration issues, unfortunately ntext is all I am allowed to use.  I am having difficulty sorting it though... when I use:

SELECT * FROM ...some table... ORDER BY ...something...

I get an error, and when I looked on the net, aparently ntext cant be sorted.   Does anyone know of a solution to this...?

Thanks guys.
0
Comment
Question by:jakekula
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
ram2098 earned 500 total points
ID: 11889993
By default, TEXT, NTEXT, and IMAGE data is stored separately from the rest of the data in a table. The table itself (in the appropriate columns) contains a 16-bit pointer that points to separate data pages that contain the TEXT, NTEXT, or IMAGE data. The reason this is done is to enhance performance.

I think you can sort the data only if you change the data type to varchar/nvarchar.
0
 
LVL 11

Expert Comment

by:ram2098
ID: 11890010
Another work around for this...

You can copy this data to a temporary table where you actually declare this column as varchar and sort it based on the column..

or else

select * from testtest order by convert(varchar(2000),test2) --in the order by ..do an explicit conversion as I shown in the query
0
 
LVL 11

Expert Comment

by:Otana
ID: 11890028
Try this:

SELECT * FROM ...some table... ORDER BY cast(something as nvarchar(4000))
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now