3
I often copy the results of a query from Sql Server Management Studio to Excel because I can fiddle with sorting and filtering of results faster using Excel's built in tools than by changing the query I'm running in SSMS. To do this I select everything in the SSMS results grid and just paste it into Excel. For the most part it works correctly; the one exception is that the formatting picked for date time columns isn't suitable and needs to be changed manually afterwards.
My date time values look like: 11/2/2012 3:34:39 PM
Excel defaults to showing 34:39.0
(MM:SS.S
)
I want a format that shows the full date and time. I do this by selecting the date time columns, selecting format cells from the context menu and picking one of the formats that show both available under the Number-Date or Number-Time options (normally 3/14/01 13:30
; the last option under time).
I'd like to change the default format Excel picks when encountering a time value to that so I don't need to fix it up every time.
Is it allowed to pre-format the Excel sheet before you paste your content? Lets say you select all cells and set them as text. Will that fit your needs? Or do you need some automatic column type detection? – nixda – 2013-02-14T21:43:47.103
@nixda No twice over. Firstly: Open Excel, change cell format, paste data isn't any less tedious than open Excel, paste data, change cell format. Secondly, if the data I'm pasting has numeric columns I want those to be treated as numbers for the purpose of sorting not as text. – Dan is Fiddling by Firelight – 2013-02-14T21:47:55.077