Syntax error converting the varchar value

  • Here is part of my sp;

     
    
    Select
    DisplayName=
    Case @SortOrder
    when 1 then
    Cast(CSI.CSICode as varchar)+ ' ' + CSI.CSIName
    when 2 then
    Submittal.SubmittalStatusID
    when 3 then
    Company.CompanyName
    else
    Submittal.SubmittalName
    end,

    the problem is with Cast(CSI.CSICode as varchar)+ ' ' + CSI.CSIName.

    CSICode is varchar(10)

    CSIName is varchar(50)

    however the data in CSICode is all integers so it seems to making DisplayName int. how do I prevent this?

    thanks-chris

    </cm>


    </cm>

  • Try a cast around the entire case statement:

    
    
    Select
    DisplayName= CAST(
    (Case @SortOrder
    when 1 then
    Cast(CSI.CSICode as varchar(10))+ ' ' + CSI.CSIName
    when 2 then
    Submittal.SubmittalStatusID
    when 3 then Company.CompanyNameelseSubmittal.SubmittalName
    END) AS varchar(50))

    Edited by - jpipes on 05/14/2003 06:14:52 AM

  • Thanks for the quick reply. I also go this to work

    Cast(CSI.CSICode as char(10)) + ' ' + CSI.CSIName


    </cm>

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply