SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 from sql server to excel cannot copy and paste
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

learning_grsql
Posting Yak Master

218 Posts

Posted - 10/14/2012 :  13:14:49  Show Profile  Reply with Quote
I have a column in sql server with data type nvarchar(50) and its values are both numbers and alphabets.

My queries are something similar to


select code from table1
where owner = 'abc'


output :

00032
000xy
00abc
00253
00012
0000a
00001

When copy and paste the output in excel, the values that are in numbers like '000032' are just pasted as '32' in excel. Similarly, 00012 as '12' and '00001' as '1'.

I'm not sure if I have to make any change in sql server query or sql server data type to make understand the excel or if it is something related to excel issue.

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/14/2012 :  15:04:44  Show Profile  Reply with Quote
This is a case of Excel trying to be helpful and interpreting data that looks like numbers to be numbers. What you can do is select the cells/columns in the Excel sheet and (right-click, select format cells and) select Category as Text under the number tab, BEFORE pasting the data.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000