Showing posts with label System Views. Show all posts
Showing posts with label System Views. Show all posts

Tuesday, 14 February 2017

How to find the SQL Server Last Restarted date & time ?

One of the easiest way to find when SQL server was restarted is using Dynamic Management view (DMV).

In some of the scenarios we need to know when the SQL server was restarted.

DMV

SELECT * FROM SYS.DM_OS_SYS_INFO

Example

I have taken the Sqlserver_start_time column from the above view.

So now my SQL server instance restarted time is 2017-02-08.

Saturday, 17 September 2016

How to find all the user defined Stored Procedure in SQL server ?

In SQL server we can get the name and definition of the stored procedure & function using System View called INFORMATION_SCHEMA.

The following example provides you the list of stored procedure in the AdventureWorks database.


We can get the definition of the stored procedure in the ROUTINE_DEFINITION Column.

In above query i used the Routine_Type as PROCEDURE , So it returns only the stored procedure list and you can get the list of functions by passing the Routine_Type as Function.