Formating data for export

  • I have the need to export decimal data to a text file without the decimals.  Is it possible to format this data a follows:

    before: 12345.67

    after 1234567

    TIA,

    Curtis

  • Declare @a as decimal(18,4)

    set @a = 12345.67

    Select replace (@a, '.', '')

    --123456700

    please note that you'll always get 4 decimals even if it's an integer

  • Piggy-backing on Remi, try this:

    SELECT

     REPLACE(REPLACE(RTRIM(REPLACE(@a,'0',SPACE(1))),SPACE(1),'0'),'.','')

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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