SQL report when copied into Excel looses format

Here is a sample of a column in my report in SQL.    The patient's account number is a randomly generated number in the system:


When I paste this in Excel the column converts to GENERAL and the number looks like this:


I want to export as a CVS file type so I do I keep the original number that was used in the SQL report .

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brian CroweDatabase AdministratorCommented:
In short, don't use Excel.  Excel is notorious for making it's best bet as to the datatype of the incoming data and then screwing it up.  In this case it is assuming you are passing in numbers based on the first value and then formatting everything in the column as a number when what you really want is text.

If this is just a one-off then change the column to "Text" and then recopy the data otherwise we can talk about alternatives.
NorieAnalyst Assistant Commented:
Are you doing this manually?

If you are have you tried formatting the column you are going to paste into as Text before you paste?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kvrogersAuthor Commented:
I will try this in the morning as I am getting ready to leave work.  Will let you know then if the formatting before I copy the text works.  

I did try selecting the column and changing it to TEXT after I pasted it in and all it did was move the numbers over to the far right.  It did not change the numbers at all.    So the first number remained 10 instead of 0010.  

Jim HornMicrosoft SQL Server Data DudeCommented:
Export the numbers as a varchar column with a single quote mark ' as the first character, and Excel will interpret it as a string and keep the leading zeros.

Otherwise Excel interprets it as a number, and as you are observing numeric data types do not support leading zeros.
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.