I need to measure how much time it takes for the MSSQL-2012 to compile a stored procedure.
Is it possible?
I need to measure how much time it takes for the MSSQL-2012 to compile a stored procedure.
Is it possible?
Yes, you can get this information. It is buried inside properties of the select statement in an actual execution plan. To do that:
However, I'm not sure how accurate or what measures this information displays.
I am assuming, you want to discover how much it does affect your performance. You can search this article for 'compile time' https://technet.microsoft.com/en-us/library/cc966540.aspx
Adding to @Vladimir's answer:
If you wanted to handle this in a more programmatic way, you should review @PaulWhite's answer to essentially the same question, also here on DBA.SE: How to measure or find cost of creating a query plan?. That answer shows how to query the DMV's for this data.
And, if you wanted to do this on a larger scale to possibly try variations of queries to later compare, check out the answers to this question which cover both storing the plans in a DB to compare via T-SQL as well as exporting them to disk: Export Query Plans