Quite often you will need the columns from a Query Analyser result for further handling, to put as header in Excel or to use in another query. The sad part is that they are not easily captured, if you get the result as a grid you can't reach them and if you get the result as text they are separated with spaces to the length of the content of each column.
So this is my street/no fuss solution - it might be faster ways of doing this will SQL but this is one way.
- Execute the SQL-statement you want the columns for and return the result as text
- Select and copy the header row
- Paste the header row into a Notepad-document
- Search for space (" ") and replace with two commas (,,)
- When done do another search for two commas and replace with one comma
- Repeat step 5 until only one comma exits
- There you go - the columns separated with commas
As i read this i see that it's quite a lot of steps, but hey you also get to watch some interesting search/replace-execution in Notepad. Always something.
Published byon Last updated