converting nvarchar to decimal on export

  • Hello All.

    Have a connection string that I use to pull data into an excel table.

    The issue I have is that one column (hours)is exporting as general but need it to come down as decimal

    I have tried to cast and convert, as well as *1.0 but it will not work.

    The column (hours) properties are nvarchar 255,null

    And have both single char and decimals

    5

    4.75

    8.5

    SELECT Convert(decimal(18,2), hours)*1.0 as hours

    FROM [dbLookups].[dbo].[TTDATA]

    full join dblookups.dbo.tblcolhierarchy

    on empid = empid

    How do I format it in my query so it will automatically come down as decimal?

    Thanks

  • Excel tries to be clever and will base formatting on a sample of the records it sees up-front.

    If you want explicit formatting then some programming may be required.

    There was a question on formatting excel recently, have a search.

    ---------------------------------------------
    If data can screw you, it will; never assume the data are correct.

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

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