September 2, 2010 at 2:31 pm
Hi folks,
I need to get a list of all object(View, Function, and Procedure)'s name for a designated database, I need the schema's info, for table, currently I am using:
select * from sysobjects where xtype = 'U' and Left(name, 3) NOT IN ('sp_', 'xp_', 'ms_', 'dt_')
This will give me the name list, however, it doesn't return schema's name, so for example, in AdventureWorks, it returns table Production.ProducProductPhoto as ProducProductPhoto.
Thanks.
September 2, 2010 at 3:08 pm
September 2, 2010 at 3:22 pm
SELECT s.name + '.' + o.name
FROM sys.objects o
JOIN sys.schemas s
ON s.schema_id = o.schema_id
WHERE o.type = 'U'
why we need "AND LEFT(o.name, 3) NOT IN ('sp_', 'xp_', 'ms_', 'dt_')" in the WHERE clause
It does not make any difference in the result.
September 2, 2010 at 3:24 pm
Slightly modified version of that same query
SELECT s.name + '.' + o.name
FROM sys.objects o
JOIN sys.schemas s
ON s.schema_id = o.schema_id
WHERE o.type = 'U'
And OBJECTPROPERTY(o.object_id,'Ismsshipped') = 0
Here, we use Objectproperty to determine which ones are user created.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
September 2, 2010 at 3:29 pm
anand_vanam (9/2/2010)
SELECT s.name + '.' + o.nameFROM sys.objects o
JOIN sys.schemas s
ON s.schema_id = o.schema_id
WHERE o.type = 'U'
why we need "AND LEFT(o.name, 3) NOT IN ('sp_', 'xp_', 'ms_', 'dt_')" in the WHERE clause
It does not make any difference in the result.
Some databases will have the dt_ as a table in the result set. Though it is a table, you probably don't want to include it because it is technically an ms shipped table.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply