Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Inserting A Decimal Point

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-05-02 : 08:21:05
backd00r writes "I'm importing data from a text file (fixed delimited).

Column 7 is a call duration field (phone call data).

Format is ‘9999v9’. (‘v’ is assumed decimal point). (eg 23.5 minutes would be |00235|).

How do I insert that deciaml point, and keep the formatting? ("00235" to "0023.5"). Can this be done at import stage, or must this be performed as a seperate script?

Currently all fields are formatted as char."

twhelan1
Yak Posting Veteran

71 Posts

Posted - 2006-05-02 : 09:57:27
SELECT cast(LEFT(call_duration, LEN(call_duration) - 1) + '.' + RIGHT(call_duration, 1) as numeric(9,1))

Yes it can be done at import, you just need to modify your import script to manipulate that field as in the example above.

Store the data in decimal form in the database, handle your formatting (leading zeros) in the display layer of your application.

~Travis
Go to Top of Page
   

- Advertisement -