Monday, March 19, 2012

How to add strings to NTEXT data type

Hi, All,
First of all thanks for reading my post. I’m trying to figure out how to
add strings to a NTEXT data type column.
TABLE (
NoteID VARCHAR(10) PRIMARY KEY,
NoteOppID VARCHAR(10) FOREIGN KEY,
NoteDetails VARCHAR(1000)
)
I need to take all NoteDetails in the above table and group by NoteOppID and
insert them into a single NTEXT field…
i.e)
NoteOppID NoteDetails (VARCHAR)
----
Opp123 Matt please send this customer a prototype
Opp123 Customer wants to see the G Series
Opp123 John, I send customer prototype I'll get back to
you on their response.
Opp456 Customer is not satisfied with the 12000 Series
components.
Opp456 John - Please give me your thoughts on this
-- End result should look like
OppId Details (NTEXT)
----
Opp123 Matt please send this customer a prototype
[New Line]
Customer wants to see the MIR 900 Series
[New Line]
John, I send customer prototype I'll get back to
you on their response.
Opp456 Customer is not satisfied with the 12000 Series
Components
[New Line]
John - Please give me your thoughts on this
I cannot leave it at VARCHAR because I'll go over the 8kb constraint.
I’ve tried…
SELECT [NTEXT] + VARCHAR -- Errors
SELECT SUBSTRING([NTEXT], 0, DATALEN([NTEXT]) + VARCHAR – works but
potentially [NTEXT] will be larger than the 8kb constraint.
Thanks,
-NeilAphex3000 (Aphex3000@.discussions.microsoft.com) writes:
> First of all thanks for reading my post. I'm trying to figure out how to
> add strings to a NTEXT data type column.
You will most likely need to use WRITETEXT and UPDATETEXT. Please look
these up in Books Online.
(Or you upgrade to SQL 2005 where you can use nvarchar(MAX) instead
which is a lot easier to deal with.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

No comments:

Post a Comment