﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by bitbucket  / VIEWS 2 / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 02:04:12 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Nice One..</description><pubDate>Thu, 10 Jan 2013 06:34:55 GMT</pubDate><dc:creator>Dineshbabu</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>very good question...unfortunately I checked wrong answer :(</description><pubDate>Wed, 10 Oct 2012 03:34:49 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>wasn't obvious for me. never thought that it is possible to delete data in a view</description><pubDate>Thu, 02 Aug 2012 05:56:11 GMT</pubDate><dc:creator>BudaCli</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>I think the question is a bit obviousWhy?1) It is a view not a table. If you want to delete any columns, you can do it by excluding from view2) It is a view so use view as a view not as a table</description><pubDate>Fri, 16 Mar 2012 02:58:19 GMT</pubDate><dc:creator>unlu.mehmet</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>:hehe:</description><pubDate>Fri, 16 Mar 2012 02:54:15 GMT</pubDate><dc:creator>unlu.mehmet</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Good question. Thanks for submitting.</description><pubDate>Wed, 14 Mar 2012 19:50:23 GMT</pubDate><dc:creator>Britt Cluff</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>tks Ron</description><pubDate>Wed, 14 Mar 2012 12:31:32 GMT</pubDate><dc:creator>OzYbOi d(-_-)b</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>[quote][b]Hugo Kornelis (3/13/2012)[/b][hr]...The view above allows people to add personnel into the Marketing department, or to update a row to transfer someone from Sales to Accounting. The WITH CHECK option prevents that, while still allowing users to update a row to transfer people between Sales and SalesBackOffice.[/quote]oh... it was not what I tought...good thing I ask :-DSo much to learn... so much to understand...so much to remembered... good thing you are there!Thanks Hugo for the precision!Thanks bitbucket for the question!</description><pubDate>Tue, 13 Mar 2012 17:31:23 GMT</pubDate><dc:creator>tilew-948340</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>[quote][b]SQLRNNR (3/13/2012)[/b][hr]Got any more like this Ron?[/quote]ONe more called VIEW 3 scheduled for the 20th of March and 2 more pending have been submitted .. waiting to be scheduled.</description><pubDate>Tue, 13 Mar 2012 15:35:11 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Got any more like this Ron?</description><pubDate>Tue, 13 Mar 2012 15:22:30 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>[quote][b]tilew-948340 (3/12/2012)[/b][hr]I am not sure to understand perfectly the WITH CHECK option.[/quote]Put simply, WITH CHECK means that rows that are inserted or updated through the view must still satisfy the view's predicate. In other words, if you do an insert or update through the view and then a select immediately after it, you should see the updated or inserted row.Example:[code="sql"]CREATE VIEW SalesPplAS  SELECT EmpNo, Name, Salary, Department  FROM Personnel  WHERE Department IN ('Sales', 'SalesBackOffice');[/code]The view above allows people to add personnel into the Marketing department, or to update a row to transfer someone from Sales to Accounting. The WITH CHECK option prevents that, while still allowing users to update a row to transfer people between Sales and SalesBackOffice.</description><pubDate>Tue, 13 Mar 2012 01:50:30 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>[quote][b]Hugo Kornelis (3/12/2012)[/b][hr] ... And if the view includes the WITH CHECK option, those people would also be unable to change active members to non-active members.[/quote]I am not sure to understand perfectly the WITH CHECK option. From microsoft, I found that "WITH CHECK option" is:      "Forces all data modification statements that are executed against the view to follow the criteria set within select_statement."  So, If I understand well, all column from the view are protected against updates, but you can delete any row from the view (if it does not have reference constraint) or insert a new row ( if the view covers all "not null" columns).  Is that it?  That could be neet...</description><pubDate>Mon, 12 Mar 2012 18:47:12 GMT</pubDate><dc:creator>tilew-948340</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Another thing that people should be cautious about when deleting a single row in a view: if the view is updateable (so that you can delete without an instead of trigger), has no trigger, and has duplicate rows and the (single) underlying table doesn't (so it's a view that doesn't include the whole of the primary key of the underlying table) and you ensure deleting a single row in the view by using "delete top (1) ...." it will delete one of the rows in the underlying table.  Since the underlying table doesn't have any duplicates, it makes sense to ask "which row" for the underlying table (it doesn't make sense to ask that for the view, because in the view you can't distinguish between the duplicate rows).   The only way you can find out is to suck it and see.</description><pubDate>Mon, 12 Mar 2012 11:33:47 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>I don't say it's a bad question because it's obvious what answer is intended, and the intended answer for the first view is right whenever the view is an updateable one, which most views whose columns are columns of a single underlying table are, and the intended answer for the second view is right whenever that view doesn't have an "instead of delete" trigger.  It will probably make people think and/or consult BoL and learn something, and perhaps at least learn to be careful about deleting through views, so it's far more good than bad.  But it's not really good because the real answer about delete from each view is "it depends". The question doesn't specify that the first view is an updateable view. Just create a trivial view with with select distinct (so that it is not an updatabale view) and straight away any attempt to delete a row using this view will fail with an error.  Since it's made "with columns in table one" some of the ways of making an non-updateable table are ruled out but certainly using "distinct" isn't and neither is anything involving both TOP and the WITH CHECK OPTION.  It isn't even clear that a view where a column is constructed from columns (plural) of the underlying table rather than from a single column of the underlying table is ruled out by the wording of the question (try having a column made by adding two columns of the underlying table, and once again it won't work), and it's certainly triue for example that an aggregates like MAX(col_x) is make from column col_x so the wording doesn't rule out the use of aggregates (and aggregates make the view non-updateable).  It depends on teh view definition of the first view.fr teh second view, although the question specifies that neither table has any trigger it doesn't specify that the views don't have triggers - so the second view could perfectly well have an "instead of delete" trigger that did something sensible, so no error message.  It depends on whether a suitable trigger exists for the second view.</description><pubDate>Mon, 12 Mar 2012 11:24:11 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Simple yet important concept on views where multiple tables are involved regardless of indexes, primary or foreign keys.  Thanks for the question.</description><pubDate>Mon, 12 Mar 2012 10:25:57 GMT</pubDate><dc:creator>zymos</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>[quote][b]Neela Khatri (3/12/2012)[/b][hr]...In the options available to be checked, results was spelled wrong twice ...[/quote]And I thought this was to help find the correct answers :laugh:Check it out--the two options where it reads [i]resu[b]tl[/b]s[/i] are the correct ones.Cheers,Michael</description><pubDate>Mon, 12 Mar 2012 08:11:54 GMT</pubDate><dc:creator>michael.kaufmann</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Thanks for the question.  Got one option right, the other wrong so I have learnt something today.  Thanks for this and as always for the discussion.</description><pubDate>Mon, 12 Mar 2012 07:30:50 GMT</pubDate><dc:creator>skanker</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Excellent question, thanks</description><pubDate>Mon, 12 Mar 2012 07:23:14 GMT</pubDate><dc:creator>Brigadur</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Thanks for an easy one :-)</description><pubDate>Mon, 12 Mar 2012 07:23:05 GMT</pubDate><dc:creator>Peter Trast</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>This was a good question, but please check your spelling before submitting the question.In the options available to be checked, results was spelled wrong twice and delete was spelled wrong once.This make a good question look bad.</description><pubDate>Mon, 12 Mar 2012 07:01:08 GMT</pubDate><dc:creator>Neela Khatri</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Good back-to-basics question.Thanks, Ron</description><pubDate>Mon, 12 Mar 2012 04:46:52 GMT</pubDate><dc:creator>Stewart "Arturius" Campbell</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Nice "real world" question today. Thanks.</description><pubDate>Mon, 12 Mar 2012 04:30:35 GMT</pubDate><dc:creator>Richard Warr</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Good job I wasn't in Oracle mode.Nice question.</description><pubDate>Mon, 12 Mar 2012 02:56:20 GMT</pubDate><dc:creator>paul s-306273</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>A good, solid question. Too bad it's only worth 1 point, I think 2 points would have been called for here.[quote][b]tilew-948340 (3/10/2012)[/b][hr]Since then, I put only "SELECT" permission on the views to make sure that nobody messed up with the data base without knowing it!  [/quote]Many people do the reverse - they give nobody any permissions on the base tables and give permissions on views only. For insert and delete, that does not really change much, but for update and select, it's a good way to show only relevant information. For instance, if your table contains a column is_active and you have a view that includes WHERE is_active = 1 and does not include columns that are only relevant to non-active members, you would give permissions on that view to the relevant users and they would never be able to see data about inactive members - neither the members, nor the columns that are relevant for inactive members.And if the view includes the WITH CHECK option, those people would also be unable to change active members to non-active members.</description><pubDate>Mon, 12 Mar 2012 02:03:14 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Nice back to basics question, thanks.</description><pubDate>Mon, 12 Mar 2012 00:07:31 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>nice and easy question since it is mostly what I am doing now :-)I would not have said that some time ago: I deleted a row in a view and discovered that the row in the parent table has been deleted too!!!! :crazy:  I always tought that a view "is a view", not that it could be an "interface" with a table!!!Since then, I put only "SELECT" permission on the views to make sure that nobody messed up with the data base without knowing it!  Thanks for the question!</description><pubDate>Sat, 10 Mar 2012 18:36:14 GMT</pubDate><dc:creator>tilew-948340</dc:creator></item><item><title>VIEWS 2</title><link>http://www.sqlservercentral.com/Forums/Topic1264774-1222-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/View/88805/"&gt;VIEWS 2&lt;/A&gt;[/B]</description><pubDate>Sat, 10 Mar 2012 11:26:23 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item></channel></rss>