Simple Concatenation Question

Simple Concatenation Question

am 02.04.2008 15:44:44 von t8ntboy

Here's what I have:

SELECT (Term + CRN) AS Comb
FROM dbo.SAS

Both Term and CRN are Int fields.

When it concatenates it is adding the values together.

For example:

Term CRN Comb
5 18 23
6 11 17


What I want is:

Term CRN Comb
5 18 518
6 11 611


How can this be done?

Thanks

Re: Simple Concatenation Question

am 02.04.2008 16:06:42 von mark

SELECT CAST(Term AS VARCHAR(10)) + CAST(CRN AS VARCHAR(10)) AS Comb
FROM dbo.SAS

Re: Simple Concatenation Question

am 02.04.2008 16:22:19 von Plamen Ratchev

If the values for the CRN column do not exceed 100, then you can do:

SELECT Term * 100 + CRN AS Comb
FROM dbo.SAS

Otherwise Mark's suggestion to concatenate as strings will work.

HTH,

Plamen Ratchev
http://www.SQLStudio.com