Solved

SQL Server Import/Export Wizard data conversion component

Posted on 2015-01-07
2
2,693 Views
Last Modified: 2015-01-09
Hi all, I have a table in a SQL Server 2008 Database which has a column called AltIndustries in nvarchar(max) format.  I ran into an error while trying to export this table to a tab-delimited text file and receive the error:

"Error 0xc020802e: Data Flow Task 1: The data type for "input column "AltIndustries" (301)" is DT_NTEXT, which is not supported with ANSI files. Use DT_TEXT instead and convert the data to DT_NTEXT using the data conversion component.
 (SQL Server Import and Export Wizard)"

A couple of things:  
The column is the output of a company function that defines its output as nvarchar(max) so that is working as expected.  

Apparently there's a data conversion component to the Import/Export wizard which I'm unaware of.  Does anyone know how I can install this component and use it?

I was able to get around the issue this time by CASTing the output of the function as CHAR(2000) but would like to gain greater understanding about the solution given in the error message.  I expect that I will be running into this again and the output then may be longer.  I'm trying to find a solution where I don't have to test the output length and modify code to insure the cast has enough space.

Comments?

Thanks, Rich
0
Comment
Question by:RichNH
2 Comments
 
LVL 32

Accepted Solution

by:
bhess1 earned 500 total points
ID: 40536556
First - Did you try checking the Unicode box on the Choose a Destination box in the export wizard? That would mean that you are not exporting to an ANSI file, but a Unicode file.

If that doesn't work for you, The simplest way to perform the data conversion is in the source specification.  Instead of just choosing "Copy data from one or more tables or views", choose "Write a query to specify the data to transfer". The create a SELECT statement on the source table, and when you enter the AltIndustries column, put it in a CAST statement - CAST(AltIndustries as varchar(MAX)) as AltIndustries

If for some reason neither of these options work, you might have to create a view on the source with the conversion in the view. However, both of the above options SHOULD work for you.
2
 
LVL 1

Author Closing Comment

by:RichNH
ID: 40541011
The Unicode didn't work but the VARCHAR(MAX) did when I tested it.   Thank you.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ms sql stored procedure 22 77
Update foreign key reference after insert 9 36
Help with SQL Query 23 39
Sort by Month and Year - SQL 3 23
Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

747 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

11 Experts available now in Live!

Get 1:1 Help Now