Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Concatenation

Author  Topic 

John T.
Posting Yak Master

112 Posts

Posted - 2003-04-21 : 10:12:49
I have some varchar fields that I wish to concatenate before inserting them into another column. The character I see for doing so(in my text) is one I don't find on my keyboard. Any help appreciated.
Have field1 and field2. Would like them to end up :
field1(field2). In vb I know it is :
<code>
field1 & "(" & field2 & ")"
</code>
Thanks in advance.

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-04-21 : 10:17:21
Hi

Try :


Select field1 + '(' + field2 + ')' AS MyConcatField
From Table



Damian

Edited by - merkin on 04/21/2003 10:17:53
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-04-21 : 10:17:29
Ummmm...you don't have a plus sign(+)

If the fields are char then:

Declare @field1 char(10), @field2 char(10)
Select @field1 = 'A', @field2 = 'B'
SELECT RTRIM(@field1)+'('+RTRIM(@field2)+')'

What'dya think



Brett

8-)
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-04-21 : 10:18:39
8 Seconds. BOOYAH!

Damian
Go to Top of Page

John T.
Posting Yak Master

112 Posts

Posted - 2003-04-21 : 10:23:16
Thanks very much. I'm laughing like crazy about the + sign. You can see I have it!

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-04-21 : 10:38:16
Damian, Even though you beat me by 8 seconds (I never said I was a fast typer), you're name still appeared as the last post...It wasn't until John reposted until it got replaced

Begs the question though, are there any other concat operators?



Brett

8-)
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-04-21 : 10:46:03
quote:

Damian, Even though you beat me by 8 seconds (I never said I was a fast typer), you're name still appeared as the last post...It wasn't until John reposted until it got replaced



Yeah that's because I edited it a little after I posted. If you edit, it puts your name in the last posted column.

Damian
Go to Top of Page
   

- Advertisement -