Useful command in SQL

Below are few SQL useful commands

-- Gives Server Name and version
SELECT @@VERSION 
-- Gives Current dataBase Name 
SELECT DB_NAME() 

-- To Find dependiblity of an Object(Table/View)
EXEC SP_DEPENDS TableName

-- To find Index associated with Object
EXEC SP_HELPINDEX TableName

-- Returns information about the roles in the selected database. 
SP_HELPROLE

-- To find Constraint on Table 
EXEC SP_HELPCONSTRAINT TableName
GO
-- To list all tables in selected database
EXEC SP_TABLES 
GO
-- To list all stored procedures in selected database
EXEC SP_STORED_PROCEDURES
Advertisements

#useful-commands