Solved

Sort ntext

Posted on 2004-08-25
5
500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

825 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