September 19, 2007 at 6:16 am
Hi,
I have a requirement to concatenate two fields together, however I cannot get the syntax of the code correct.
I need to join field1 + '/' + field. I have tried :-
CAST(FIELD1 AS varchar(10)) + '/' + FIELD2 As fulltext,
Unfortunately this does not work.
Any advice anyone?
Nick
September 19, 2007 at 6:40 am
What are the data types of the 2 columns - can you give us sample data?
What error do get ?
September 19, 2007 at 6:56 am
Hi,
Thankyou for your reply, the fields are :-
Field1, Field2
23116,02 etc etc
The output would need to be 23116/02.
Thanks
Nick
September 19, 2007 at 7:11 am
HI Nick,
What are the data types of your fields?
If they are both INT's then if you cast both of them to VARCHAR it should work 100%
Thanks
Chris
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
September 19, 2007 at 7:21 am
HI,
They field one is varchar, field two is int.
Nick
September 19, 2007 at 8:01 am
HI Nick,
Make sure that you cast Field2 to a varchar before trying to concatenate the fields.
If both vars are varchars at the point on concatenating then it will def work.
Thanks
Chris
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
September 19, 2007 at 8:08 am
Field1 is already VARCHAR? And Field2 is INT?
CAST(FIELD1 AS varchar(10)) + '/' + FIELD2 As fulltext,
Field1 + '/' + CONVERT(VARCHAR, Field2) AS FullText
N 56°04'39.16"
E 12°55'05.25"
September 19, 2007 at 9:14 am
Spot on .... Thanks.
Nick
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply