Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 from sql server to excel cannot copy and paste

Author  Topic 

learning_grsql
Posting Yak Master

230 Posts

Posted - 2012-10-14 : 13:14:49
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
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-14 : 15:04:44
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
   

- Advertisement -