Here are some SQL commands that we rarely use but are very useful in simulations when we want to see the objects that exist in our database. These include :

1. Get list tables in database :

SELECT * FROM sys.Tables

2. Get list Stored procedures in database :

SELECT * FROM sys.procedures;

3. Get list User defined functions in database :

SELECT name AS function_name, SCHEMA_NAME(schema_id) AS schema_name, type_desc FROM sys.objects WHERE type_desc LIKE ‘%FUNCTION%’;

4. Get constraints in database :

SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint, SCHEMA_NAME(schema_id) AS SchemaName, OBJECT_NAME(parent_object_id) AS TableName, type_desc AS ConstraintType FROM sys.objects WHERE type_desc LIKE ‘%CONSTRAINT’

5. Get detailed Stored procedure :

sp_helptext <Stored_Procedure_Name>

6. Execute a Stored procedure in SQL :

EXEC <StoredProcedure_Name>

If the stored procedure has spaces in its name, enclose it between double quotes