SQL 2005: T-SQL Get table name or Stored Procedure name

How to get all the tables' name?

Select * 
From sysobjects
Where type = 'U'
Order By name
Change the type to 'P' and you will get all the Stored Procedures.
Change the type to 'F' and you will get all the UDF (User-Defined Function).
More details from here.

Another way to get the tables:
Select *
From sys.tables

How to get the content of stored procedures?
Select text From syscomments Where id = 
(Select id From sysobjects Where type='P' and name = 'SprocName')
or
Exec sp_helptext SprocName
I prefer the second one.

0 Comments:

Random Posts

Powered by Stuff-a-Blog