Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Insert spaces into a decimal field Expand / Collapse
Author
Message
Posted Thursday, August 19, 2010 12:36 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 9:30 AM
Points: 403, Visits: 982
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 "+ "?
Post #971636
Posted Thursday, August 19, 2010 2:15 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, December 19, 2010 10:52 PM
Points: 30, Visits: 213
Can u please make it clear?
Post #971664
Posted Thursday, August 19, 2010 2:29 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:02 AM
Points: 39,866, Visits: 36,207
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 2008, MVP
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

Post #971671
Posted Thursday, August 19, 2010 7:41 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 9:30 AM
Points: 403, Visits: 982
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.
Post #971866
Posted Thursday, August 19, 2010 7:50 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:02 AM
Points: 39,866, Visits: 36,207
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 2008, MVP
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

Post #971873
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse