Calculate Execution and Cpu Time in SQL 2005/2008

If we want to know cpu time and elapsed time of a sql statement then we have to SET STATISTICS TIME ON.
Just consider following example


SET STATISTICS TIME ON

Select * from TableName

-- Or Any Query

SET STATISTICS TIME OFF



Then it will show following output

SQL Server parse and compile time:
CPU time = 31 ms, elapsed time = 141 ms.