Forum Discussion

Suvechha's avatar
Suvechha
Copper Contributor
Feb 24, 2025

Having difficulties to paste data to excel ?

Hi,

I need to provide data in excel format. 

One of the field is having varchar - I am using 

CAST(AP.IDINVC AS VARCHAR) as [INVOICE_ID] 

But I am missing the leading zero's when I copy the data from MS SQL Server Result to excel file.

No of rows is 147474.

How to keep the leading zeros when copying the Invoice ID from MS SQL Server result to Excel.

1 Reply

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

    But I am missing the leading zero's when I copy the data from MS SQL Server Result to excel file.

    Has nothing to do with MS SQL Server, but with Excel.

    If the cells are formatted as "Default", the Excel interpret the values as nuerics; numeric don't have leading zeros and so Excel removes them.

    Format the cells as "Text" and Excel keeps the zeros.

     

Resources