SQL View not showing as changed
TroyHusker
Posts: 5
I'm using SQL 2000 and I added a field to a table. But I also had to recompile a view that includes all of the fields of that table using the "*" to get all fields because it wasn't picking up the new field.
When I ran SQL Compare, it didn't see the view as having been changed and therefore didn't update the other database that was the recipient of the original changes. Is there some sort of setting I need to select so that it can pick up those view changes?
Hopefully I'm making a little bit of sense. I'm not sure how else to explain it as I'm not very technical in my speach.
Thanks so much for a great product!
When I ran SQL Compare, it didn't see the view as having been changed and therefore didn't update the other database that was the recipient of the original changes. Is there some sort of setting I need to select so that it can pick up those view changes?
Hopefully I'm making a little bit of sense. I'm not sure how else to explain it as I'm not very technical in my speach.
Thanks so much for a great product!
This discussion has been closed.
Comments
The view doesn't need to be changed, really, because it's still a SELECT * FROM... in both databases. But it does need to be recompiled so that internally, SQL Server knows specifically which columns are part of the *. This is done using sp_refreshview. SQL Compare is designed in version 5 to script an sp_refreshview as part of the synchronization, which is important if you have a view or stored procedure that depends on another view that is a SELECT *.
Please let me know if the issue is that sp_refreshview isn't being scripted where it needs to be.
Thanks!
I hope that helps some.
Again, thanks for a great product. It has saved me hours and hours of time.
Yep it looks like you have found an issue here; if the view is identical but there is a difference in a permission or an extended property then the view will not be refreshed correctly.
There is a workaround for your problem: if you run with the ignore permissions and ignore extended properties options enabled the views will refresh correctly. Then if you run another synchronisation with these options now disabled you can then sync up the permissions and extended properties.
I understand that this is not perfect, I have raised this with the development team but I don't have an outlook as to when this issue will resolved at the moment.
Regards,
Jonathan
-Project Manager
-Red Gate Software Ltd
Cool! So I'm NOT going crazy. :-)
I also actually found that as long as I don't go into the view (after changing the table) and change something around causing an extended properties change, and also be sure to choose "Include Dependencies" when synchronizing, it will actually run the recreate/recompile command on the view. It's only when there is some difference in the extended properties or permissions (as you said) that it WON'T run the recompile/recreate command. So, if I will just leave well enough alone, and not try to do too much, I'll be alright. :lol:
Anyway, as you said, this product is not perfect, but it sure is awfully close!
Have a GREAT day!