Solved

How to get list of all view created by a user

Posted on 2001-08-29
17
279 Views
Last Modified: 2012-06-21
How can I get a list of all the views created by a particular in SQL Server. ADOX views object doen't work properly with SQL oledb provider. I cannot use SQL-DMO due to licence problem.
How can I get just the names of all view created by user by querying the database
0
Comment
Question by:bravi
  • 9
  • 8
17 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
select * from sysobjects
where xtype = 'V'
and uid = (select id from sysusers where <whatever> )

CHeers
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
select * from sysobjects
where xtype = 'V'
and uid = (select id from sysusers where <whatever> )

CHeers
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
sorry for the double post...

or

select * from INFORMATION_SCHEMA.views
where TABLE_SCHEMA = 'dbo'

CHeers
0
 

Author Comment

by:bravi
Comment Utility
I don't need any system views, only user views are required
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
What about these queries:

select * from sysobjects
where xtype = 'V'
and uid > 1

or

select * from INFORMATION_SCHEMA.views
where TABLE_SCHEMA <> 'dbo'

Cheers
0
 

Author Comment

by:bravi
Comment Utility
I don't need any system views, only user views are required
0
 

Author Comment

by:bravi
Comment Utility
I need all user views created by a paricular user. What if a particular user has dbo privilege? I won't get even the user created views in that case
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
You are right, there is no indication WHO did actually create the table, only to which user the tables are assigned...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:bravi
Comment Utility
I need all user views created by a paricular user. What if a particular user has dbo privilege? I won't get even the user created views in that case
0
 

Author Comment

by:bravi
Comment Utility
There should be some way to filter out this information, enterprise manager displays the type of view also (system or user).
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
In fact, in the systems table there is a column that indicates if the views are build by the system, but not by which user they are created. Take the following example:

You have USERA and USERB, both with dbo permissions...

USERA connects to the server, and executes the following script:
CREATE VIEW USERB.MyViewA
AS SELECT ...
GO
CREATE VIEW USERA.MyViewB
AS SELECT ...
GO
CREATE VIEW MyViewC
AS SELECT ...

and USERB connects, and executes a similar script:
CREATE VIEW USERB.MyView1
AS SELECT ...
GO
CREATE VIEW USERA.MyView2
AS SELECT ...
GO
CREATE VIEW MyView3
AS SELECT ...


If you look at EM, you will have 6 views:
USERB.MyViewA
USERA.MyViewB
USERA.MyViewC
USERB.MyView1
USERA.MyView2
USERB.MyView3

BUT not all the views that are owned by UserA are actually created by UserA (and vice-versa). All the views have the bit "systemobject" set to false, but there is no indication to which user actually create it...

Cheers


0
 

Author Comment

by:bravi
Comment Utility
Can you tell me where this systemobject flag can be found, even that would be useful to me. Thanks
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
using the sysobjects, the status column > 0 ...
CHeers
0
 

Author Comment

by:bravi
Comment Utility
Can you tell me where this systemobject flag can be found, even that would be useful to me. Thanks
0
 

Author Comment

by:bravi
Comment Utility
Is it reliable? Books online says its reserved for internal use only. Anyway thanks, I will accept the answer
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
Comment Utility
You are right, it's internal use only... and the values can differ for sometimes no obvious reason.
For views however, i am sure it can be used reliable way.
Cheers
0
 

Author Comment

by:bravi
Comment Utility
Is it reliable? Books online says its reserved for internal use only. Anyway thanks, I will accept the answer
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Server Log File Space 6 33
Calculating Business Hours 19 59
SQL JOIN 6 27
BULK INSERT most recent CSV 19 17
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now