Insert spaces into a decimal field

  • Is it possible to insert into a 9-byte decimal field (with allow nulls) a value of "+________" , i.e., spaces from 2 to 9th byte. If there is "+0 ", then it gets loaded into the field. Tried loading with all 9-bytes as spaces, even then it gives "Error converting data type nvarchar to numeric". Is there no way to insert spaces or "+ "?

  • Can u please make it clear?

  • There is no way. Decimal is a numeric field, it can store numbers only and anything inserted into it is converted to a numeric representation. A space is not a number and cannot be stored in a numeric field.

    What are you trying to do? It sounds like formatting, and that's something that typically should be done in queries, not in the data.

    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
  • am trying to load a Text file to a table through SSIS. Usually, the decimal column in text file would have say "+23456789" or "-23456789". Presently, the file has "+--------" i.e. only "+" is existing with the other bytes being white spaces.

  • Add a derived column transform in SSIS where you remove the spaces from the data. I think there's a replace function in there. Either replace ' ' with '' or replace ' ' with '0'

    The + is not a problem, it's just the spaces.

    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

Viewing 5 posts - 1 through 4 (of 4 total)

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