Change dot separated value to a comma separated value

  • Hello, 
    I need to insert value to a sql server table which is then the source for excel worksheet.
    Simple, but I have two problems.
    First, values in worksheet are dot separated (123.123) and i want them to be comma separated and the other thing is that some values in worksheet are interpreted as DATE values.
    Could you please help me to solve the problem?
    Closest i came up is this code below but it moves separator to the end of value and it becomes 123456781234.0000
    DECLARE @zmienna decimal(19,4)
    SET @zmienna = 12345678.1234

    INSERT INTO TestTable
    SELECT REPLACE(REPLACE(CAST(@zmienna as numeric(19,4)),'.',''),'.',',')

  • lukaszpiech - Thursday, December 13, 2018 5:30 AM

    Hello, 
    I need to insert value to a sql server table which is then the source for excel worksheet.
    Simple, but I have two problems.
    First, values in worksheet are dot separated (123.123) and i want them to be comma separated and the other thing is that some values in worksheet are interpreted as DATE values.
    Could you please help me to solve the problem?
    Closest i came up is this code below but it moves separator to the end of value and it becomes 123456781234.0000
    DECLARE @zmienna decimal(19,4)
    SET @zmienna = 12345678.1234

    INSERT INTO TestTable
    SELECT REPLACE(REPLACE(CAST(@zmienna as numeric(19,4)),'.',''),'.',',')

    Surely this is a display/presentation issue?
    Storing commas in numeric data turns that data into useless text.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Storing commas in numeric data turns that data into useless text.

    This info changes my decision. I will leave data as it is and i'll try to solve problem in different way.

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

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