General discussion

Locked

SQL NText field concatenation?

By andrew ·
Is there a way to concatenate 2 NText fields using T-SQL?

I'd like to do sometheing like:
INSERT Table2 (SELECT NText1 + NText2 from Table1)

The '+' concatenation operator is disallowed for Text and NText datatypes.

I'm using MS SQL Server7.0

TIA

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

SQL NText field concatenation?

by Limbo In reply to SQL NText field concatena ...

Andrew,

Yes there is, use this explicit conversion:

SELECT CAST(NText1 AS VARCHAR(8000)) + CAST(NText2 AS VARCHAR(8000)) FROM TABLE1


If you have concerns about maintaining the datatype outputted the cast as follows

SELECT CAST(CAST(NText1 AS VARCHAR(8000)) + CAST(NText2 AS VARCHAR(8000))AS NTEXT) FROM TABLE1


SQL Server 7 does not support image data types and text datatypes in the fashion you'd expect. Another problem, SQL limits this cast or conversion to 8000 charactersonly.

If this proves too limiting then I'm afraid you may have to use another datatype for your fields.

Collapse -

SQL NText field concatenation?

by andrew In reply to SQL NText field concatena ...

I had thought of this, but I need to handle data beyond 8000 characters.

Thanks anyway.

Collapse -

SQL NText field concatenation?

by Limbo In reply to SQL NText field concatena ...

Q: Can MS SQL 7 concatenate nText fields?
A: No. (See above)

Perform your function at the application layer not at the DB layer if you can not alter the datatypes.

Collapse -

SQL NText field concatenation?

by Limbo In reply to SQL NText field concatena ...

Ah well... It is a republic after all

Collapse -

SQL NText field concatenation?

by andrew In reply to SQL NText field concatena ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums