Solved

Can I covert XML data type to varchar

Posted on 2011-09-05
3
1,191 Views
Last Modified: 2012-05-12
Hi All,
Can I convert XML data type from table to varchar, by recreating table.
I tried with following commands,
EXPORT TO ABC.ixf' OF ixf select * from ABC
drop table ABC;
Create table ABC with Varchar column.
LOAD CLIENT FROM ABC.ixf' of ixf insert into ABC;

But While loading I m getting error as
SQL3088N  The source column specified to be loaded into database column "1" is not compatible with the database column, but the database column is not nullable.

Please advise me about Is it possible to convert XML to varchar.
0
Comment
Question by:harsha_james
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 36483527
how about trying

create table abc2 (col varchar(...))

insert into abc2
select cast(xml_column as varchar)
from abc

drop abc
renambe abc2 to abc
0
 

Author Comment

by:harsha_james
ID: 36486726
Thanks Momi,
This trick solved my problem.
But is it safe to do this because on Production system, If XML data exceeds varchar limit i.e. 32672  chars then My insert will fail.
Thanks for your support.
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 36487812
you are correct, but you wanted to convert it to varchar
run a test with an xml longer than 32672 and see what happens
you can either try to cast it to clob, or break it to several varchar values or just truncate after the first 32672 bytes
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

751 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