Solved

SQL Server Import/Export Wizard data conversion component

Posted on 2015-01-07
2
3,516 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL query and VBA 5 46
SQL Syntax Grouping Sum question 7 27
SSRS: Why is Visual Studio stripping these properties? 2 23
RAISERROR WITH NOWAIT 2 18
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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 …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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.

820 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