0

I am trying to export data from Oracle PLSQL to Excel. The data type of one of the column is VARCHAR2. The Column conatins value like 00798019859217. But after exporting, the value in excel is something like this 7.9802E+11.

PLease let me know how to resolve this and the reason for this format issue.

Thanks in advance.

5
  • try exporting to csv instead of excel Commented Nov 26, 2014 at 10:05
  • There is no data typeVARCHAR2 in SQL Server. Commented Nov 26, 2014 at 10:34
  • Try exporting with a single quote in the front. Commented Nov 26, 2014 at 10:47
  • What is the relevance of the reference to SQL Server in this question when you have tagged it Oracle and PLSQL? Commented Nov 26, 2014 at 11:43
  • meta.stackexchange.com/questions/5234/… Commented Mar 17, 2017 at 15:53

2 Answers 2

1

Do the following:

  1. Select the column with single quotes, say

    SELECT ("'" || COLUMN_NAME) AS COLUMN_NAME, OTHER_COLUMNS FROM MY_TABLE
    

    Output will be like:

    'ABC0157976
    '00798019859217
    
  2. Export the output to an excel.In excel "A" column values will be

    'ABC0157976
    00798019859217   (Single quote will not be visible for number only values)
    
  3. Select the entire "A" row and clear all single quotes with replace all option. You will get final excel as.

    ABC0157976
    00798019859217 
    

Since it is a text field and non-numeric characters are also expected to be present, the step#3 is required. If it is going to be only numeric characters, then step #3 can be ignored.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi thanks for your response. For some rows the column value will be null. In that case single quote (') alone is coming in the excel. How to avoid that..
USE SELECT ("'" || NVL(COLUMN_NAME,'DUMMY_VALUE') AS COLUMN_NAME. After step#3, also clear all cells containing value as "DUMMY_VALUE"
@karthika: Please accept as answer by clicking the grey mark by the side if this answer helped you. Thank you!
0

This is happening due to excel where the number auto casted. As @HamidP said try exporting as csv and check with opening in notepad or text, and check whether the number displaying fully or not. If so then you can open the same in Excel with small options change such

Right click the cell and click format option and make it cell format as text and then save the excel.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.