Object Information 1

Object Information

--list all the tables         
SELECT name AS [Tables] FROM sys.objects WHERE OBJECTPROPERTY(object_id, 'isUserTable')<>0
--list all the Scalar functions
SELECT name AS [Scalar functions] FROM sys.objects WHERE OBJECTPROPERTY(object_id, 'IsScalarFunction')<>0
--list all the Table Functions
SELECT name AS [Table Functions] FROM sys.objects WHERE OBJECTPROPERTY(object_id, 'IsTableFunction')<>0
--list all the Procedures
SELECT name AS [Procedures] FROM sys.objects WHERE OBJECTPROPERTY(object_id, 'IsProcedure')<>0
--list all the Triggers
SELECT name AS [Triggers] FROM sys.objects WHERE OBJECTPROPERTY(object_id, 'IsTrigger')<>0

Here is what the above code is Doing:
1. It’s creating a new database called “MyDatabase”
2. It’s creating a new table called “MyTable” with two columns: “Id” and “Name”
3. It’s inserting a new row into “MyTable”
4. It’s selecting all the rows from “MyTable”
5. It’s dropping the “MyTable” table
6. It’s dropping the “MyDatabase” database

Similar Posts