Solved

Can I covert XML data type to varchar

Posted on 2011-09-05
3
1,163 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
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
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…

776 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