SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Tracking changes on Views.


Tracking changes on Views.

Author
Message
ben.brugman
ben.brugman
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10317 Visits: 2770
Tracking changes in/on Views.

Are there any good scripts/documents/advises/tips on Tracking changes on Views?

I asume that I am not the first person to try this.
Thanks for your time and attention,
Ben
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (211K reputation)SSC Guru (211K reputation)SSC Guru (211K reputation)SSC Guru (211K reputation)SSC Guru (211K reputation)SSC Guru (211K reputation)SSC Guru (211K reputation)SSC Guru (211K reputation)

Group: General Forum Members
Points: 211286 Visits: 24531
ben.brugman - Monday, February 26, 2018 6:18 AM
Tracking changes in/on Views.

Are there any good scripts/documents/advises/tips on Tracking changes on Views?

I asume that I am not the first person to try this.
Thanks for your time and attention,
Ben

Do you mean view definition changes, or changes to the data returned by the view?



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
ben.brugman
ben.brugman
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10317 Visits: 2770
Phil Parkin - Monday, February 26, 2018 6:29 AM

Do you mean view definition changes, or changes to the data returned by the view?

Changes in the content which have to be tracked. (Sorry, :-( I was not clear about that).
(When the view definition does NOT change).

Ben

Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)

Group: General Forum Members
Points: 351081 Visits: 34271
Best way to do this is to put your database code into source control. You can track it and version it that way. Further, once you start treating your database as code, you can start to automate deployments since builds from source control allow you to go from a known state.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
Product Evangelist for Red Gate Software
GilaMonster
GilaMonster
SSC Guru
SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)

Group: General Forum Members
Points: 896382 Visits: 48655
Triggers on the tables that make up the view (trigger on the view doesn't fire unless the view itself is the target of the modification)

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


ben.brugman
ben.brugman
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10317 Visits: 2770
Grant Fritchey - Monday, February 26, 2018 7:33 AM
Best way to do this is to put your database code into source control. You can track it and version it that way. Further, once you start treating your database as code, you can start to automate deployments since builds from source control allow you to go from a known state.

Thanks Grant Fritchey.
Tracking changes of the content. Or changes of the data returned by the view.
Not the 'source' of the view.

I think that your anwser reveres to changes in the 'definition'. Or am I misunderstanding your anwser ?
Thanks for your time and attention,
Ben

Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)SSC Guru (351K reputation)

Group: General Forum Members
Points: 351081 Visits: 34271
ben.brugman - Monday, February 26, 2018 7:45 AM
Grant Fritchey - Monday, February 26, 2018 7:33 AM
Best way to do this is to put your database code into source control. You can track it and version it that way. Further, once you start treating your database as code, you can start to automate deployments since builds from source control allow you to go from a known state.

Thanks Grant Fritchey.
Tracking changes of the content. Or changes of the data returned by the view.
Not the 'source' of the view.

I think that your anwser reveres to changes in the 'definition'. Or am I misunderstanding your anwser ?
Thanks for your time and attention,
Ben


Sorry, you said changes in "content" not data or the code. I misunderstood what content meant. Gail has the better answer for this. It's all about tracking the data in the tables. There is no data in a view. It's just a query.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
Product Evangelist for Red Gate Software
ben.brugman
ben.brugman
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10317 Visits: 2770
Sorry for the confusion, I should have paid more attention to the situation. (English is not my first language, so although I do check the things that I have written. I tend to read what I think, I have written.)

From another database we get (with an ODBC connection) tables and thereafter the mutations on the tables into a SQLserver database. The source database is not exactly relational. The mutations from the source get processed in the tables (in SQLserver). So at that point we have the tables and the mutations (in tables).

The tables are not totally 'logical' and do not really fit into the 'model'. So we are using views to create a beter model of the data.
Persisting the views is easy, just create a tables of the views. But now we want the mutations on the view. So the Inserts/Updates and Deletes needed to have the persisted table to contain the same data as the view. (The updates can also be done with only inserts/deletes).

As usual this is a simplified representation, everything is done within economical constraints and the usual 'management' constraints, it has to be good/cheap/quick.

Offcourse; I told the management that we can do good/cheap/quick, but only two of them at the same time. For me this is a challenging puzzle, but I do like that. But do not mind scripts/documents/advises/tips to get a better/faster/cheaper :-) result.
Ben
GilaMonster
GilaMonster
SSC Guru
SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)SSC Guru (896K reputation)

Group: General Forum Members
Points: 896382 Visits: 48655
Triggers on the tables beneath the views, with logic to determine whether the changes that fired the trigger would affect the views or not.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Subramaniam Chandrasekar
Subramaniam Chandrasekar
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3440 Visits: 531
ben.brugman - Monday, February 26, 2018 6:18 AM
Tracking changes in/on Views.

Are there any good scripts/documents/advises/tips on Tracking changes on Views?

I asume that I am not the first person to try this.
Thanks for your time and attention,
Ben

Can't we create a copy of the view as a table and compare it daily using an user defined function. In user defined function you can check and compare both source and destination tables.

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search