t-sql Export to Excel

ukerandi
ukerandi used Ask the Experts™
on
in the sql results is showing customer number is 01NOV02,02NOV02..etc, after export to the Microsoft Excel sheet ,its showing the 01-Nov-02.
I try usig Convert (varchar(50,[Customer Number])) but after export to the excel its showing date format (01-Nov-02.
) how to export to the Excel with out changing to the dae format?

Many thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
SQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015
Commented:
The problem isn't that SQL Server is pumping data in the incorrect format, it's the way Excel interprets the data type of that data when it's opened.   So, your options are to either pump the data with a single apostrophe ( ' ) in the front so Excel can interpret it as a string, or write Excel VBA code in the startup function to format the column as a string.
RayData Analyst

Commented:
You can export to a csv or txt file then open excel (not the file itself, just Excel), then use the Excel "File" menu to "open" the file, but BEFORE opening use the options at the bottom of the window to "import" the file.  Ensure you set that column as TEXT before allowing it to import.
HuaMin ChenProblem resolver
Commented:
Try to put

 ''''+'01NOV02'

on t-Sql, to make it as one char field instead.
Ryan ChongSoftware Team Lead

Commented:
>>how to export to the Excel with out changing to the dae format?
when you try to import them, set the column data format as Text

column data format to Text
Ryan ChongSoftware Team Lead

Commented:
sorry, disregard comment ID: 40962103 as didn't see Ray already posted same suggestion.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial