February 6, 2013 at 8:56 pm
Comments posted to this topic are about the item Updating Views
February 6, 2013 at 8:58 pm
Nice question .... but Steve had I know it was you who created the QOD would still having me wondering what the answer might be.
February 6, 2013 at 9:34 pm
Nice question Steve!
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
February 6, 2013 at 9:35 pm
bitbucket-25253 (2/6/2013)
Nice question .... but Steve had I know it was you who created the QOD would still having me wondering what the answer might be.
+1
Definitely, I would have also thought that there is some kind of gotcha 🙂
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
February 6, 2013 at 11:19 pm
Nice question Steve, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
February 7, 2013 at 12:21 am
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.
Manik
Go fast as possible
Manik
You cannot get to the top by sitting on your bottom.
February 7, 2013 at 12:23 am
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..
--
Dineshbabu
Desire to learn new things..
February 7, 2013 at 12:36 am
Lokesh Vij (2/6/2013)
Nice question Steve!
+1
Thanks for the question.......
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
February 7, 2013 at 1:02 am
Hi mani,
Thanks for spending your time to explain about schema Binding.
manik123 (2/7/2013)
If MyView is schema bind no one will be able to alter the dbo.MyTable table unless they drop the table.
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.
manik123 (2/7/2013)
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.
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...
--
Dineshbabu
Desire to learn new things..
February 7, 2013 at 1:03 am
Please some one list the limitations of schema binding a view.
--
Dineshbabu
Desire to learn new things..
February 7, 2013 at 1:28 am
Steve - 0 points to you for creating a view using 'select *'...
😛
February 7, 2013 at 1:42 am
Good question, Steve!
Here is a link to the most recent version of the relevant Books Online article: http://msdn.microsoft.com/en-us/library/ms187821.aspx. 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.
February 7, 2013 at 2:02 am
paul s-306273 (2/7/2013)
Steve - 0 points to you for creating a view using 'select *'...😛
+1 - Apart from that - good question 😀
-------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
February 7, 2013 at 2:04 am
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 it
Using "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.)
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
February 7, 2013 at 2:14 am
paul s-306273 (2/7/2013)
Steve - 0 points to you for creating a view using 'select *'...😛
So how should Steve have made a QotD about the dangers of select * in a view without using select * ???
Viewing 15 posts - 1 through 15 (of 33 total)
You must be logged in to reply to this topic. Login to reply