Domanda

I have a column (varchar(35),null) in a SQL table of survey results (using SQL Server Management Studio) of unique IDs. When I run queries, display the table on dashboards, etc. everything works fine. However, when I try to save the query results as a .csv file or copy/paste into an Excel, it's always replacing the last character with a 0. So for instance 117951372014878 will be become 117951372014870. Any ideas as to why this is happening or what I might do in the short/long-term to fix is?

Thoughts?

È stato utile?

Soluzione

Excel is interpreting like a number everything that looks like a number - just like your id. And since it has limited numeric presicion (about 15 significant digits), it looks like the last digits are replaced by 0 (in fact, the whole number is rounded).

To avoid this, change the cell format to text before pasting and use Paste special... -> values only.

For CSV it might be sufficient to enclose the values in double quotes, though I'm not 100% sure about this.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top