35

I'm trying to paste my query results from Mgmt Studio to Excel, but for whatever reason the columns in Mgmt Studio are concatenated into a single column when pasted into Excel.

This doesn't happen to any of my colleagues and we couldn't find any settings for changing this. Any ideas?

4

5 回答 5

64

This is an issue with Excel.

After you paste the results into Excel, go to the "data" option and choose "Text to Columns". Then click on "delimited" and be sure that "tab" is checked on the next window.

This will convert the data into columns. And, Excel remembers the settings, so it will paste correctly the next time.

于 2012-08-17T00:57:05.350 回答
4

I had the exact same problem. Yesterday it worked, but today it just pasted everything into the first column as text. Used to automatically be pasted from the Management Studio columns into Excel columns.

It's Excel. It remembers your text-to-column choices from last time you used the function in Excel and applies them automatically next time you copy-paste.

You can indeed just use the text-to-columns function again with tabs selected as delimiter. Then after that this choice is remembered and stored in Excel. Now if you copy from Management Studio again and paste it will snap into the columns as expected.

Seems it's one of those instances where Excel tries to help you but ends up being a bit annoying :)

于 2016-07-15T08:55:11.247 回答
2

I have solved this problem in my SSMSBoost add-in for SSMS: it has possibility to export grid as native OpenXMLSpreadsheet, which can be easily "understood" by excel. As "bonus" to solution of your problem you will also see that even datatypes are preserved, so no problems anymore with conversion of dates to text or text to numbers... Check it out.

于 2013-06-05T01:38:16.870 回答
0

I get this too and in the past i would shut down excel. I realized after a while that every day i do text to columns for a specific spreadsheet and i change the delimiter to other /. When i change it back to tab, it works fine.

于 2020-12-01T16:04:10.373 回答
-2

I ran into the same issue. I was able to get my results to a CSV using the following solution:

  1. Execute query
  2. Right click in the top left corner of the results grid
  3. Select "Save Results as.."
  4. Choose csv and viola!
于 2014-10-17T19:38:44.723 回答