C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Databases »

How to sort the TEXT data type


Posted Date: 24 Jul 2008    Resource Type: Articles    Category: Databases
Author: koorasrinivasMember Level: Bronze    
Rating: 1 out of 5Points: 5



How to sort the TEXT data type

Essentially, we cannot use the ORDER BY clause on text, unitext, or image datatype columns. However we can SORT the TEXT by converting it to VARCHAR/CHAR.


Example:

create table JobDetails
(
JobId int,
JobName char,
JobDescr text
)
insert into JobDetails values (1,'AAA','This Stored Procedure clears all input tables')
insert into JobDetails values (2,'BBB','Get the Processing date corresponding to the current data')
insert into JobDetails values (3,'CCC','This SP clears up the work tables so that fresh data can be loaded for the processing days processing')
insert into JobDetails values (4,'DDD','Stored Procedure inserts the statistics for the existing records for which data is received at the same day')
insert into JobDetails values (5,'EEE','This Stored Procedure clears all input tables')
insert into JobDetails values (6,'FFF','Get the Processing date corresponding to the current data')


Select * from JobDetails order by JobDescr ? This query will not execute

Solution: We have to convert the “TEXT” data type to VARCHAR/CHAR to sort it

Select * from JobDetails order by convert(varchar(1200),JobDescr)




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
How to sort the TEXT data type  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to delete the Duplicate records in sql
Previous Resource: Creating Crystal Reports using Visual Studio 2005
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use