Showing posts with label views. Show all posts
Showing posts with label views. Show all posts

Sunday, March 25, 2012

Can we alter system views in SQL Server 2005?

Hi, all experts here,

Thank you for your kind attention.

Would please anyoneh ere give me any advices about if we can alter system views in SQL Server 2005 ?

With best regards,

modifying system objects is no longer allowed in sql2k5...|||Can you let us know of your scenario which requires you to alter the system views ?|||

Hi, Asvin,

Thank you very much for your kind attention.

The original reason for me to wonder if it is possible to alter system objects was that since in SQL Server 2005 we got a INFORMATION_SCHEMA.COLUMNS view which collects the information about all the columns within the database, but what I think will be helpful is the description for the columns. Since I am currently having a large database with up to serveral hundred tables which got a large number of columns without any explanation for what are those columns about, as a result, it's been very difficult to understand the whole database to have further analysis based on it.

If database designer could put description for each column within the database, and at the same time add a column_descpription column into the INFORMATION_SCHEMA.COLUMNS within the system view, it will be very helpful for other users rather than database designers to understand the data well.

Hope my explanation above clear what my question is and thank you very much in advance for your further advices and guidance.

With best regards,

Yours sincerely,

|||

If that is your intent I would suggest that you add extended properties on the table columns. Take a look at this feature at http://msdn2.microsoft.com/en-us/library/ms190243.aspx.

or look it up in books online.

In short, extended properties let you add a description to any object in the database such as tables, views, schemas, columns etc.

e.g.

To add an extended property to a column of a table you could do something like

sp_addextendedproperty 'property_name','your description','schema','schema_name_of_table','table','table_name','column','column_name'

and then to retrieve it you can use the function fn_listextendedpropety or the catalog view sys.extended_properties.

select * from sys.fn_listextendedproperty('property_name','schema','schema_name_of_table','table','table_name','column','column_name') will return 'your description'.

Hope this helps and is a good starting point to solve your problem.

Please do not attempt to modify or change the system views in sql server. It will leave the database in a corrupt state.

Can we alter system views in SQL Server 2005?

Hi, all experts here,

Thank you for your kind attention.

Would please anyoneh ere give me any advices about if we can alter system views in SQL Server 2005 ?

With best regards,

modifying system objects is no longer allowed in sql2k5...|||Can you let us know of your scenario which requires you to alter the system views ?|||

Hi, Asvin,

Thank you very much for your kind attention.

The original reason for me to wonder if it is possible to alter system objects was that since in SQL Server 2005 we got a INFORMATION_SCHEMA.COLUMNS view which collects the information about all the columns within the database, but what I think will be helpful is the description for the columns. Since I am currently having a large database with up to serveral hundred tables which got a large number of columns without any explanation for what are those columns about, as a result, it's been very difficult to understand the whole database to have further analysis based on it.

If database designer could put description for each column within the database, and at the same time add a column_descpription column into the INFORMATION_SCHEMA.COLUMNS within the system view, it will be very helpful for other users rather than database designers to understand the data well.

Hope my explanation above clear what my question is and thank you very much in advance for your further advices and guidance.

With best regards,

Yours sincerely,

|||

If that is your intent I would suggest that you add extended properties on the table columns. Take a look at this feature at http://msdn2.microsoft.com/en-us/library/ms190243.aspx.

or look it up in books online.

In short, extended properties let you add a description to any object in the database such as tables, views, schemas, columns etc.

e.g.

To add an extended property to a column of a table you could do something like

sp_addextendedproperty 'property_name','your description','schema','schema_name_of_table','table','table_name','column','column_name'

and then to retrieve it you can use the function fn_listextendedpropety or the catalog view sys.extended_properties.

select * from sys.fn_listextendedproperty('property_name','schema','schema_name_of_table','table','table_name','column','column_name') will return 'your description'.

Hope this helps and is a good starting point to solve your problem.

Please do not attempt to modify or change the system views in sql server. It will leave the database in a corrupt state.

sql

Can views be used in query builder?

I tried it but got an invalid object error. I then copied and pasted the sql statement contained in the view but it doesn't run correctly inside query builder and only shows 1 valid row, and a 2nd row that's blank the the first column and has a number 1 in the second column. The view runs correctly in SQL Server Management Studio Express.

How about wrapping the view inside a stored procedure?

|||

Stored procedures can't be used in query builder either. All I can do is put in a dummy SQL statement (like Select 1 as column1, 2 as whatever) and then change it to a stored procedure later when I have access to the "data" tab in [Design].

That doesn't seem right but is the only way I can figure out how to do it.

Thursday, March 22, 2012

Can user view objects they only have select permission on?

I have a user that belongs to a role. This role only has select permissions
on 10 views. When I log in as this user via Management Studio I cannot see
the views however I can execute queries against them.
On another server that I did not setup, that I'm supposed to be mimicking
the same security, this same user can see the views.
Any ideas what the difference is?
Thanks!Here's the commands that I'm executing in order:
CREATE ROLE [Customers_ROLE] Authorization dbo
CREATE SCHEMA [Customers_Schema] AUTHORIZATION [Customers_Role] Deny
View
Definition to [Customers_Role]
exec sp_adduser 'phenson', 'phenson', [Customers_Role]
GRANT SELECT ON [dbo].[PT_VIEW] TO [Customers_Role]
When I log in as phenson I do not see PT_View but I can query on it. I need
to be able to see it.
"SpankyATL" wrote:

> I have a user that belongs to a role. This role only has select permissio
ns
> on 10 views. When I log in as this user via Management Studio I cannot se
e
> the views however I can execute queries against them.
> On another server that I did not setup, that I'm supposed to be mimicking
> the same security, this same user can see the views.
> Any ideas what the difference is?
> Thanks!|||I thought I'd answer my own question for those of you who come across this
some day. I need to remove the "Deny View Definition" portion and that took
care of it. The user was able to see that view and execute it but could not
see the script.
"SpankyATL" wrote:
[vbcol=seagreen]
> Here's the commands that I'm executing in order:
> CREATE ROLE [Customers_ROLE] Authorization dbo
> CREATE SCHEMA [Customers_Schema] AUTHORIZATION [Customers_Role] De
ny View
> Definition to [Customers_Role]
> exec sp_adduser 'phenson', 'phenson', [Customers_Role]
> GRANT SELECT ON [dbo].[PT_VIEW] TO [Customers_Role]
>
> When I log in as phenson I do not see PT_View but I can query on it. I ne
ed
> to be able to see it.
> "SpankyATL" wrote:
>|||SpankyATL (SpankyATL@.discussions.microsoft.com) writes:
> Here's the commands that I'm executing in order:
> CREATE ROLE [Customers_ROLE] Authorization dbo
> CREATE SCHEMA [Customers_Schema] AUTHORIZATION [Customers_Role] De
ny View
> Definition to [Customers_Role]
> exec sp_adduser 'phenson', 'phenson', [Customers_Role]
> GRANT SELECT ON [dbo].[PT_VIEW] TO [Customers_Role]
>
> When I log in as phenson I do not see PT_View but I can query on it. I
> need to be able to see it.
Why then did you do DENY VIEW DEFINITION to a role that you made phenson a
member of?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||I was working from a script that was given to me. The person who developed
it mistakenly thought deny view would only deny the user from viewing the
source code.
"Erland Sommarskog" wrote:

> SpankyATL (SpankyATL@.discussions.microsoft.com) writes:
> Why then did you do DENY VIEW DEFINITION to a role that you made phenson a
> member of?
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx
>