Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to convert an ntext field to text when reading from the DB?

Posted on 2009-05-02
1
Medium Priority
?
319 Views
Last Modified: 2012-05-06
We are reading a SQL Server 2000 database and writing its contents out to a text file via our ASP web page.

The problem is that because the fields are defined as ntext, the resulting file is written out as unicode (we're just using the Scripting.FileSystemObject to create a text file and it appears to automatically be saving it as a unicode file).

This is a problem because the 3rd party system we send the text file off to cannot process the unicode data.

QUESTION: Is there a function we can use in our SQL query to have SQL convert the ntext field to text so that the resulting string from the recordset is a non-unicode string?

Thanks experts!
0
Comment
Question by:rascal
1 Comment
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 2000 total points
ID: 24287544
>>Is there a function we can use in our SQL query to have SQL convert the ntext field to text so that the resulting string from the recordset is a non-unicode string?<<
Yes.  You can use CONVERT() or CAST() as in:

Select CAST(YourNTextColumn As text) SomeAlias
From YourTable

0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

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

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

577 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