Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert TEXT to NVARCHAR?

Status
Not open for further replies.

gkrenton

MIS
Jul 2, 2003
151
US
So it seems that informix won't let me substr or substring a TEXT field....Anyone know how I can convert a TEXT field into a Nvarchar or something else that I can then put into a distinct sql query?

- gina
 
Hi,

you cannot address text-fields via string-functions, cause these are BLOB-Fields, which must be handled diffently.

what you can do:

- load/unload text-fields via unload/load-statements

i.e. you could do:

Code:
create table m1 (field1 text, field2 varchar(255));

create a text-file m1test.unl with following content:

Code:
This is a text|<blank>

load this textfile into your table:

Code:
load from m1test.unl insert into m1;

select contents from table using subscripts

Code:
select field1[1,4] from m1;

will result in

Code:
field1
This

you cannot

update m1 set field2=field1[1,255];

so you could do something like that:

Code:
unload to m1trans.unl select field2, field1 from m1;
delete from m1 where 1=1;
load from m1trans.unl insert into m1;

hope this helps!
 
Thanks - complicated but helpful but at least it's a workable solution.
I appreciate the info.

- Gina
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top