Solved

How to get list of all view created by a user

Posted on 2001-08-29
17
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
17 Comments
 
LVL 143

Expert Comment

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

CHeers
0
 
LVL 143

Expert Comment

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

CHeers
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6436773
sorry for the double post...

or

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

CHeers
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

Author Comment

by:bravi
ID: 6436905
I don't need any system views, only user views are required
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6436998
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
ID: 6437021
I don't need any system views, only user views are required
0
 

Author Comment

by:bravi
ID: 6437034
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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6437087
You are right, there is no indication WHO did actually create the table, only to which user the tables are assigned...
0
 

Author Comment

by:bravi
ID: 6437109
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
ID: 6437116
There should be some way to filter out this information, enterprise manager displays the type of view also (system or user).
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6437298
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
ID: 6437357
Can you tell me where this systemobject flag can be found, even that would be useful to me. Thanks
0
 
LVL 143

Expert Comment

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

Author Comment

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

Author Comment

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

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 6437408
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
ID: 6437422
Is it reliable? Books online says its reserved for internal use only. Anyway thanks, I will accept the answer
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

690 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