Monday 13 May 2013

Get the Last Execution Date/time for a Stored Procedure

Get the Last Execution Date/time for a Stored Procedure

 
Select
b.name, s.last_execution_time from sys.dm_exec_procedure_stats s
INNER
JOIN sys.objects b
ON s.object_id = b.object_id
where s.type='P'
order by last_execution_time desc


Monday 22 April 2013

Get the List of Tables and Column having the Identity Field or Column

To get the list of tables having identity columns, we can use the INFORMATION_SCHEMA view of the SQL Server. Below is the script:

selectCOLUMN_NAME, TABLE_NAME
from
INFORMATION_SCHEMA.COLUMNS
whereTABLE_SCHEMA = 'dbo'
andCOLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1
order
by TABLE_NAME