Avatar of mmalik15
mmalik15

asked on 

Could not export sql server 2008 table's varchar (8000) column to excel 2007

while trying to export a table with varchar column(8000) to excel 2007 or 2003 i m getting the following error. The mappings show the varchar(8000) is trying to convert in long text

Could not connect destination component.

Error 0xc0204016: SSIS.Pipeline: The "output column "Question" (71)" has a length that is not valid. The length must be between 0 and 4000.


any ideas how can we fix this
Microsoft SQL Server 2008Microsoft Excel

Avatar of undefined
Last Comment
Kevin Cross
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Do you have data over 4000 characters? One simple approach would be to CONVERT(VARCHAR(4000), Question) in export query.
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

You can output as csv and then open that in excel
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

The other option, as I believe it is type conversion issue, is to convert to NVARCHAR(MAX) or NVARCHAR(8000). Aaron's suggestion looks promising also as the conversion issue is between providers, so it may just be a conflict with the Excel provider that can be overcome by going to CSV.
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

You could also cast as text instead of varchar 4000, that way you don't lose anything.

Another thought, I've had excel be unhappy with varchar(max) even though it should be the same as varchar(8000). If it is set to varchar(max) try cast as varchar(8000)
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Nice suggestions, aarontomosky. I would NOT go with a cast to TEXT, though. It is being deprecated and really should be used in SQL 2008 if can be avoided.
Avatar of mmalik15
mmalik15

ASKER

Thanks for the comments guys. I have tried exporting in csv and it exports okay. The root problem that I have is that  I have three versions of the same database. Three different people have inserted data into the same table and i need to synchronise that table now from those databases. I thought it would be easier to export in excel and use excel filter to remove duplicates and import into database again. This import/export between MS Sql server 2008 and excel 2007 is not looking very friend and i wonder if there is a better solution to acheive the desired result.

p.s. shall I put this as seperate question as the context of the problem is different now?
ASKER CERTIFIED SOLUTION
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of mmalik15
mmalik15

ASKER

As the db name is same for all the three dbs so jus rename the db's attach them all to the same instance of sql server and use insert into dbname.dbo.table select * from table where pk not in (select pk from dbname.dbo.table)

is that right?
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Change the table name, put in the columns instead of *
yep.
Avatar of mmalik15
mmalik15

ASKER

thanks again for the comments. One final issue the pk is auto genrated and could be same in different databases. Guess we should be able to filter on varchar fieids too?
SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Does the table have one unique field across the databases? Maybe you do want to make this a separate question with more detail on the table
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Sorry, I was typing and missed the other posts in the thread. Hopefully, my comment answers some of your questions. Apologies for duplication already handled in previous couple of posts from aaron.
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Agree. I think http:#36900730 should be pretty detailed to get you on the way, coupled with aaron's advice to this point; therefore, I would give it a try and then if you have specific errors or challenges post a new question. For now, it appears http:#36900535 answers the original question.
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

If I had a keyboard I'd have awesome descriptive solutions of awsomeness too ;)
Avatar of mmalik15
mmalik15

ASKER

Brilliant comments guy!

Many thanks
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Aaron,

You made some pretty "awesome descriptive solutions of awesomeness" without a keyboard. It was a pleasure collaborating with you BOTH.

mmalik15, glad we could help!

Best regards and happy coding,

Kevin
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo