Simple Concatenation Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • t8ntboy

    Simple Concatenation Question

    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
  • Mark

    #2
    Re: Simple Concatenation Question

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

    Comment

    • Plamen Ratchev

      #3
      Re: Simple Concatenation Question

      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

      Comment

      Working...