﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Steve Jones / Article Discussions / Article Discussions by Author  / Updating Views / 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>Wed, 19 Jun 2013 09:32:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Really good one! Didn't know about the SP but got it right through exclusion- of course, the only really correct answer wasn't offered.[size="-3"](drop this badly designed view and fire any dev that complains about his app crashing as a result)[/size]</description><pubDate>Tue, 26 Feb 2013 06:38:33 GMT</pubDate><dc:creator>sqlcentral-bugmenot</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Nice question.</description><pubDate>Mon, 11 Feb 2013 07:08:39 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Nince question,Thank you Steve.</description><pubDate>Mon, 11 Feb 2013 03:46:24 GMT</pubDate><dc:creator>kapfundestanley</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>I've had to correct views I've inherited that used select * and returned many unneeded columns. A quick and dirty way to correct them is to right click a view, select Open, select the 'show sql pane' button in the toolbar, and add to the displayed query WHERE 1=0 (or something of the like). I click the exclamation point and the resulting sql query string now explicitly shows all columns. You can now copy this and alter your view in a normal ssms &amp;#119;indow. It is a time saver when the view returns tens of columns.</description><pubDate>Thu, 07 Feb 2013 15:55:47 GMT</pubDate><dc:creator>mmartin1</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]L' Eomot Inversé (2/7/2013)[/b][hr][quote][b]EL Jerry (2/7/2013)[/b][hr]Got it. Here it is:[url]http://www.sqlservercentral.com/Forums/FindPost1349883.aspx[/url]Saludos,[/quote]Wow, that is a humorous thread! I am glad I don't work with that lead. Talk about misdirection...</description><pubDate>Thu, 07 Feb 2013 13:25:20 GMT</pubDate><dc:creator>KWymore</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]EL Jerry (2/7/2013)[/b][hr]Got it. Here it is:[url]http://www.sqlservercentral.com/Forums/FindPost1349883.aspx[/url]Saludos,[/quote]That is a version with some problems (misplaced '[' and ']', misplaced 'with scheamabinding' clause, using [] on identifiers in drop but not on create) which are easily fixed.  I don't know whether Barry posted a corrected version later.It was an amazing thread - I pity the OP having to put up with a lead who bases his decisions on a vivid imagination with a strong inclination towards fiction.</description><pubDate>Thu, 07 Feb 2013 13:00:28 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Got it. Here it is:[url]http://www.sqlservercentral.com/Forums/FindPost1349883.aspx[/url]Saludos,</description><pubDate>Thu, 07 Feb 2013 10:51:13 GMT</pubDate><dc:creator>EL Jerry</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Nice question, Steve. I knew the answer right away from previous posts in the forums.By the way, I remember RBarry Young posted some code that he used to run overnight in order to rebuild all views. The code looked interesting and it made sure when a table was altered its views would be accurate next day. However, I'm unable to find the post. I will do some further search and post the link to it when I find it.Saludos,</description><pubDate>Thu, 07 Feb 2013 10:43:27 GMT</pubDate><dc:creator>EL Jerry</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]alex.d.garland (2/7/2013)[/b][hr][quote][b]Hugo Kornelis (2/7/2013)[/b][hr][quote][b]paul s-306273 (2/7/2013)[/b][hr]Steve - 0 points to you for creating a view using 'select *'...:-P[/quote]So how should Steve have made a QotD about the dangers of select * in a view without using select * ???[/quote]+1 - but I note that if a warning about using "SELECT *..." had been added to the explanation, this would have been even more helpful.[/quote]Fair point and added.</description><pubDate>Thu, 07 Feb 2013 10:22:04 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]Hugo Kornelis (2/7/2013)[/b][hr][quote][b]paul s-306273 (2/7/2013)[/b][hr]Steve - 0 points to you for creating a view using 'select *'...:-P[/quote]So how should Steve have made a QotD about the dangers of select * in a view without using select * ???[/quote]Good question, great discussion, and learned from both.  Hugo has a point you cannot illustrate the problems and pitfalls without illustrating the problem or pitfall.   Our teachers use to say "Don't ever say lookin, say looking! " And then some smarty would say "But you just said lookin, why can't we?":-)</description><pubDate>Thu, 07 Feb 2013 10:03:07 GMT</pubDate><dc:creator>Miles Neale</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Good question, thanks Steve. Definitely highlights an important point when using views.</description><pubDate>Thu, 07 Feb 2013 10:00:28 GMT</pubDate><dc:creator>KWymore</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Thanks Steve</description><pubDate>Thu, 07 Feb 2013 08:58:35 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Nice 1 Steve. However, I don't recommend anyone to use SELECT * FROM in view.</description><pubDate>Thu, 07 Feb 2013 07:52:25 GMT</pubDate><dc:creator>jagpatel9</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Good question!I wondered about an ALTER VIEW statement being there as well since altering the view inherently refreshes it, but then recalled that *'s aren't allowed in schema-bound objects.  Nice!</description><pubDate>Thu, 07 Feb 2013 07:26:53 GMT</pubDate><dc:creator>sestell1</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Good question, I learned something.Generally I don't ever write views with SELECT * in them.but even if I did... If I had to refresh the view, I'd typically just alter the view and leave the code as is... that works too, or did... I haven't written a view with SELECT * in it since before SQL 2005</description><pubDate>Thu, 07 Feb 2013 07:02:54 GMT</pubDate><dc:creator>mtassin</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Good question. Thanks.</description><pubDate>Thu, 07 Feb 2013 05:56:34 GMT</pubDate><dc:creator>(Bob Brown)  </dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Good question, Steve, thanks</description><pubDate>Thu, 07 Feb 2013 04:28:56 GMT</pubDate><dc:creator>Stewart "Arturius" Campbell</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]alex.d.garland (2/7/2013)[/b][hr][quote][b]Hugo Kornelis (2/7/2013)[/b][hr][quote][b]paul s-306273 (2/7/2013)[/b][hr]Steve - 0 points to you for creating a view using 'select *'...:-P[/quote]So how should Steve have made a QotD about the dangers of select * in a view without using select * ???[/quote]+1 - but I note that if a warning about using "SELECT *..." had been added to the explanation, this would have been even more helpful.[/quote]... it is like... "never say never...."</description><pubDate>Thu, 07 Feb 2013 03:17:30 GMT</pubDate><dc:creator>Raghavendra Mudugal</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]Hugo Kornelis (2/7/2013)[/b][hr][quote][b]paul s-306273 (2/7/2013)[/b][hr]Steve - 0 points to you for creating a view using 'select *'...:-P[/quote]So how should Steve have made a QotD about the dangers of select * in a view without using select * ???[/quote]+1 - but I note that if a warning about using "SELECT *..." had been added to the explanation, this would have been even more helpful.</description><pubDate>Thu, 07 Feb 2013 03:14:33 GMT</pubDate><dc:creator>alex.d.garland</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]paul s-306273 (2/7/2013)[/b][hr]Steve - 0 points to you for creating a view using 'select *'...:-P[/quote]So how should Steve have made a QotD about the dangers of select * in a view without using select * ???</description><pubDate>Thu, 07 Feb 2013 02:14:00 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Awesome QtoD, thank you Steve.(was thinking if the 4th option will come true in future versions, would be cool, and then thought again.. setting auto to everything is not a acceptable way to go, but it would be a nice feature and a lot to consider before really using itUsing "schemabinding" and "select *" ... I do not feel comfortable using it..  i create VIEW with the specifying column names, and if needed, then alter the view to suit the new needs and modify the code to the new adjustments. Earlier i had views with select * in one of the web projects and then later I changed them to the column specifics.. and by doing that whenever it is needed I kind of gained control over the objects by knowing which object needs modification and which doesn't and i was knowing each and every VIEW object which are the tables it refers.)</description><pubDate>Thu, 07 Feb 2013 02:04:46 GMT</pubDate><dc:creator>Raghavendra Mudugal</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]paul s-306273 (2/7/2013)[/b][hr]Steve - 0 points to you for creating a view using 'select *'...:-P[/quote]+1 - Apart from that - good question :-D</description><pubDate>Thu, 07 Feb 2013 02:02:28 GMT</pubDate><dc:creator>Stuart Davies</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Good question, Steve!Here is a link to the most recent version of the relevant Books Online article: [url=http://msdn.microsoft.com/en-us/library/ms187821.aspx]http://msdn.microsoft.com/en-us/library/ms187821.aspx[/url]. It's the same aas the one in the explantion, but without the explicit version number added. (Why do people so often use links to older versions when the question is not about that older version? Why????)The true danger of using SELECT * in a view becomes apparent if, after adding that new column, the original column is then dropped. The view will still return data, still use the name of the old (no longer existing) column, but return data from the new column.</description><pubDate>Thu, 07 Feb 2013 01:42:25 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Steve - 0 points to you for creating a view using 'select *'...:-P</description><pubDate>Thu, 07 Feb 2013 01:28:05 GMT</pubDate><dc:creator>paul s-306273</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Please some one list the limitations of schema binding a view.</description><pubDate>Thu, 07 Feb 2013 01:03:24 GMT</pubDate><dc:creator>Dineshbabu</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Hi mani,Thanks for spending your time to explain about schema Binding. [quote][b]manik123 (2/7/2013)[/b][hr]If MyView is schema bind no one will be able to alter the dbo.MyTable table[b] unless they drop the table[/b]. [/quote]If a view is schema bound, even dropping the table is also not possible. Either you need to drop the view or you need to remove schema binding. You can just modify the columns which is not included in view definition.[quote][b]manik123 (2/7/2013)[/b][hr]Just think that someone drops/alters the table dbo.MyTable without paying any heed to our view. Now that would leave our view nowhere. Hence schema bind it, this will prevent any such accidents from happening. [/quote]There are few limitations in schema binding like all the objects should be within the same database. You cannot use synonyms in view definitions etc...</description><pubDate>Thu, 07 Feb 2013 01:02:20 GMT</pubDate><dc:creator>Dineshbabu</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]Lokesh Vij (2/6/2013)[/b][hr]Nice question Steve![/quote]+1Thanks for the question.......</description><pubDate>Thu, 07 Feb 2013 00:36:04 GMT</pubDate><dc:creator>demonfox</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Nice and easy one one. I got a second thought whether there is any database level set option to make a view referesh automatically.. finally I ensured there is no such option..</description><pubDate>Thu, 07 Feb 2013 00:23:07 GMT</pubDate><dc:creator>Dineshbabu</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>nice quetion... EXEC sp_refreshview MyView  is correct answer. but what is the use of 'ALTER VIEW MyView ADD SCHEMABINDING'.  Schema binding binds your views to the dependent physical columns of the accessed tables specified in the contents of the view, i.e. if MyView is schema bind no one will be able to alter the dbo.MyTable table unless they drop the table. Just think that someone drops/alters the table dbo.MyTable without paying any heed to our view. Now that would leave our view nowhere. Hence schema bind it, this will prevent any such accidents from happening. ManikGo fast as possible</description><pubDate>Thu, 07 Feb 2013 00:21:24 GMT</pubDate><dc:creator>manik123</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Nice question Steve, thanks.</description><pubDate>Wed, 06 Feb 2013 23:19:04 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>[quote][b]bitbucket-25253 (2/6/2013)[/b][hr]Nice question .... but Steve had I know it was you who created the QOD would still having me wondering what the answer might be.[/quote]+1Definitely, I would have also thought that there is some kind of gotcha :-)</description><pubDate>Wed, 06 Feb 2013 21:35:58 GMT</pubDate><dc:creator>Lokesh Vij</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Nice question Steve!</description><pubDate>Wed, 06 Feb 2013 21:34:22 GMT</pubDate><dc:creator>Lokesh Vij</dc:creator></item><item><title>RE: Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Nice question .... but Steve had I know it was you who created the QOD would still having me wondering what the answer might be.</description><pubDate>Wed, 06 Feb 2013 20:57:59 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item><item><title>Updating Views</title><link>http://www.sqlservercentral.com/Forums/Topic1416795-32-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/T-SQL/96443/"&gt;Updating Views&lt;/A&gt;[/B]</description><pubDate>Wed, 06 Feb 2013 20:56:08 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item></channel></rss>