Search code examples
exceloffice365ssms-2017

Excel Pasting SQL Server Results Set Only Into Column A


I am experiencing issues trying to paste a SQL Server SSMS results set into Excel using Copy and Paste. When I try to paste into a spread sheet all of the values go into the first column.


Solution

  • After searching the web for cause and solution to this problem, I thought I would post my findings to see if it could help someone else. Earlier in the day I had been opening some pipe-delimited files using Excel and its Text-To-Columns function on the Data tab of Excel in the most recent version of Office 365. Later I needed to paste the results of a SQL Server query from the grid into a spreadsheet and it would paste it only into the cells in Column A. After several attempts (restarting SSMS and Excel) with no change in results, I pasted the results set into Notepad++. After turning on the White Space characters I noticed the the results appeared to be Tab-Delimited. Next, I pasted the results into Excel. Again they went into the cells in Column A. I then used Text-To-Columns (using Tab as the delimiter) to get the data into columns appropriately. After that I had no problems pasting results from SSMS into Excel. It seems that Excel caches the Text-To-Columns settings from one spreadsheet to the next.