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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s