Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2004, 12:09 AM
Registered User
 
Join Date: Dec 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Concatenate TEXT Type Value

Hi..

How do I concatenate TEXT data types? I wanna do something like this:
Code:
DECLARE @myTable TABLE (LongString TEXT)
.
.
UPDATE @myTable SET
    LongString = LongString + 'string to be added'
The '+' operator wont work on TEXT types.
BTW, i'm using MS SQL 2000..

Thank you..


 
Old December 30th, 2004, 01:15 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

First of all you need to use "UpdateText" and not "Update" for Text/nText/Image columns.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old December 30th, 2004, 01:23 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(pr_info)
   FROM pub_info pr, publishers p
      WHERE p.pub_id = pr.pub_id
      AND p.pub_name = 'New Moon Books'
UPDATETEXT pub_info.pr_info @ptrval 0 3 'vadi '
GO

here 0 = starting position of the string (its zero based only)
3 = till which position to replace
'vadi ' -- text to be replaced for the characters postion 0-3


Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old December 30th, 2004, 03:15 AM
Registered User
 
Join Date: Dec 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Vadivel..

I've succeeded updating the column with UPDATETEXT.
And I believe the way to read it back is to use READTEXT, but the examples I found is to only read it to certain length.. What should I do to read until the end of the text value?

And also, how can I send the read text to a PRINT statement?


 
Old December 31st, 2004, 01:12 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

You can also use normal "Select" statement to fetcht the value of TEXT datatype. But always the TEXT column should be the last one in the list.

i.e., Select col1, col2, TextColumn from Table1

here TextColumn -- is a column of TEXT datatype. Hope this helps!

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old December 31st, 2004, 01:29 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Btw, uou can make use of datalength() to find the length of data in text column.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
code to read two text files, concatenate one...... dgr7 Beginning VB 6 2 April 18th, 2007 03:24 PM
type clash: sql_variant is incompatible with text l_ali_khan VB Databases Basics 0 April 2nd, 2007 11:02 AM
Can i use text type field in Access as primery key geetageetageeta ASP.NET 2.0 Basics 1 March 4th, 2006 09:31 AM
Content-type = text/html tarran C# 3 December 5th, 2004 08:36 AM
How To Type the text of html tag in TextBox 6cet6 ASP.NET 1.0 and 1.1 Basics 3 November 6th, 2003 05:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.