Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 30th, 2004, 12:09 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
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..


Reply With Quote
  #2 (permalink)  
Old December 30th, 2004, 01:15 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
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
Reply With Quote
  #3 (permalink)  
Old December 30th, 2004, 01:23 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
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
Reply With Quote
  #4 (permalink)  
Old December 30th, 2004, 03:15 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
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?


Reply With Quote
  #5 (permalink)  
Old December 31st, 2004, 01:12 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
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
Reply With Quote
  #6 (permalink)  
Old December 31st, 2004, 01:29 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:45 PM.


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