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!

Using concat to Update table columns.

Status
Not open for further replies.

cteare

Technical User
Jun 20, 2003
1
CA
Hi,

I'm trying to add some text to an existing entry in the table. As far as I can tell, I need to use concat. Can you use the concat command to update a column entry, using that entry as an argument to the concat function? This is what I want to try and do...

UPDATE MyTable SET update_column = concat("new string", update_column) Where identifier IN (list_of_identifiers)

Is this correct us of concat??

Thanks.

cteare
 
Hi

I do not think you can use concat in Sybase. Try this

Code:
1> use tempdb
2> go
1> create table test (some_text varchar(132) not null)
2> go
1> drop table test
2> go
1> create table test (test_id   numeric(10,0)   identity, some_text varchar(132) not null)
2> go
1> insert into test values('This is my first line')
2> go
(1 row affected)
1>  insert into test values('this is the second line longer that first line')
2> go
(1 row affected)
1> update test set some_text = some_text + ' This is additional line'
2> go
(2 rows affected)
1> select * from test
2> go
 test_id       some_text                                                                                                                          
 ------------- ------------------------------------------------------------------------------------------------------------------------------------
             1 This is my first line This is additional line                                                                                      
             2 this is the second line longer that first line This is additional line                                                       (2 rows affected)
1> declare @value char(30)
2> select @value =' here is London'
3> update test set some_text = some_text + @value
4> select * from test
5> go
(1 row affected)
(2 rows affected)
 test_id       some_text                                                                                                                          
 ------------- ------------------------------------------------------------------------------------------------------------------------------------
             1 This is my first line This is additional line here is London                                                                       
             2 this is the second line longer that first line This is additional line here is London                                              

(2 rows affected)

Make sure that the column in the table has enough width to take the new text in.
good luck and hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top