Select...Into - Specify column size

  • Is there a way to select records into a temp table and specify the size of the columns at select time?

    SELECT

    [2] AS [Size]

    , [3] AS Placement

    INTO #Parse

    FROM Split PIVOT ( MAX(value) FOR idx IN ( [1], [2]) ) AS P

    I want to the columns to have a size of varchar(50)

    I am getting a truncation error because of size of columns

    Thanks,

    vmon

  • SELECT

    CAST([2] AS VARCHAR(50)) AS [Size],

    CAST([3] AS VARCHAR(50)) AS Placement

    INTO #Parse

    FROM Split

    PIVOT ( MAX(value) FOR idx IN ( [1], [2]) ) AS P

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Excellent, thanks!

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

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