SSMS - Regex to handle stuff copied from Excel to SSMS

Post date: Dec 14, 2011 11:49:59 AM

When you copy paste from Excel into SSMS the columns will be tab separated. If you want to perform some task for each for you can start from this little snippet.

This snippet will find 4 columns and create tree rows for each row in the Excel document. The first cell in the Excel document will be present on each of the tree rows. This was used to unpivot data from an Excel document into several rows in a many-to-many table where the first column was meant to hold many of the other column (Car dealer owning many cars).

^({.*})\t({.*})\t({.*})\t({.*})$('\1', '\2'), \n('\1','\3'),\n('\1','\4'),