Comparison of source control & database not refreshing views

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, eddie davis, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

Comparison of source control & database not refreshing views

Postby matt_hosking » Fri May 04, 2012 6:24 am

I've just recently switched from script vs database comparison to source control vs database comparison (in order to support migration scripts) and noticed that views are no longer being refreshed when objects they are dependent on are modifed (i.e. a table is changed and views that use it don't get refreshed).

Is this a bug or is there a setting to fix this behaviour? My options are currently 'if,ifg,iw,ie,iq,nt,iu,iup,ip,nc' and I've tried adding 'incd' (include dependencies) but this works the reverse way (modify a function that uses a view and the view gets refreshed).
matt_hosking
 
Posts: 14
Joined: Wed Sep 07, 2011 2:43 am
Location: Australia

Postby Brian Donahue » Mon May 07, 2012 11:56 am

SQL Compare is supposed to include an sp_refreshview for every underlying table that changes - can you post the whole command you are using?
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby matt_hosking » Tue May 08, 2012 12:10 am

Here it is:
"C:\\Program Files (x86)\\Red Gate\\SQL Compare 10\\SQLCompare.exe" /sourcecontrol1 /revision1:Latest /scriptsfolderxml:"%teamcity.build.checkoutDir%\\Build\\compare.xml" /migrationfolderxml:"%teamcity.build.checkoutDir%\\Build\\migration.xml"
/scripts2:"%teamcity.build.checkoutDir%\\sourcedb" /options:if,ifg,iw,ie,iq,nt,iu,iup,ip,nc /scriptfile:"%teamcity.build.checkoutDir%\\Build\\Scripts\\%Version%b.sql"

Where %Version% = 4.0.0 (at the moment), check out dir is agent-side default check out dir and the sourcedb folder is the source-controlled (SQL Source Control) schema folder for the version to compare against (couldn't see how to supply 'scriptsfolderxml' for the second source control).

Compare.xml
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<!--
SQL Compare 10
SQL Compare
Version:10.1.0.102-->
<ISOCCompareLocation version="1" type="SvnLocation">
<RepositoryUrl>http://[removed]/trunk/database/Schema/</RepositoryUrl>
</ISOCCompareLocation>

Migration.xml
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<!--
SQL Compare 10
SQL Compare
Version:10.1.0.102-->
<ISOCCompareLocation version="1" type="SvnLocation">
<RepositoryUrl>http://[removed]/trunk/database/Migration Scripts/</RepositoryUrl>
</ISOCCompareLocation>
matt_hosking
 
Posts: 14
Joined: Wed Sep 07, 2011 2:43 am
Location: Australia

Postby Brian Donahue » Tue May 08, 2012 9:34 am

You will need to add the incd option for the refreshview to be scripted. Ommitting that is the only way I can reproduce the problem.

If this doesn't work, then your database in particular must have a dependency chain that is confusing to SQL Compare. We'll probably need schema snapshots to reproduce the issue in house so we can try to fix it.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby Brian Donahue » Tue May 08, 2012 9:37 am

Also, do you get refreshviews when you don't use your deployment scripts? The deployment script is going to replace whatever SQL Compare would have generated so if someone removed the refreshview from the deployment script, that could also have an effect, I think...
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby matt_hosking » Wed May 09, 2012 12:11 am

Hi Brian,
Thanks for the reply, but as I mentioned, I've already tried the 'incd' option, which appears to do the reverse - updates only objects that the current object is dependent on (e.g. function depends on a view), rather than the other way - update the objects that depend on the current object (e.g. views that depend on a table), which I want.

Could this have something to do with migration scripts? Have you tested using the exact command line parameter set? I've found that they do seem to interact somewhat in expected ways when used differently from the norm.
matt_hosking
 
Posts: 14
Joined: Wed Sep 07, 2011 2:43 am
Location: Australia

Postby matt_hosking » Wed May 09, 2012 2:17 am

Solved it - it appears that without the 'Default' option included, the 'sp_refreshview' calls are never included (at least for me on 10.1). So my new set of options is:

Default,ie,iq,nt,iu,ip,nc

and everything is working. This should have been equivalent to:

if,ifg,iw,ie,iq,nt,iu,iup,ip,nc,incd

shouldn't it? This set was only missing 'DecryptPost2KEncryptedObjects', 'IgnoreWithElementOrder' and 'IgnoreDatabaseAndServerName' but none of those should have affected the dependencies I would think. Is there something undocumented in the 'Default' option?
matt_hosking
 
Posts: 14
Joined: Wed Sep 07, 2011 2:43 am
Location: Australia

Postby Brian Donahue » Wed May 09, 2012 9:39 am

There is a description of the default options when you run the program using the /? /v arguments:
Default (Alias: d) -
The default options for a sensible comparison: IgnoreFillFactor,
IgnoreWhiteSpace, IncludeDependencies, IgnoreFileGroups,
IgnoreUserProperties, IgnoreWithElementOrder,
IgnoreDatabaseAndServerName, DecryptPost2kEncryptedObjects.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby matt_hosking » Thu May 10, 2012 12:08 am

I read that part (which is how I deduced the options from default I was missing), but as I mentioned, these missing options shouldn't have caused the omission of sp_refreshview or constraints handling. Is there any reason why the default option would be required in order to get this to work? Could it be specific to comparing source control to scripts and / or with migration scripts enabled?
matt_hosking
 
Posts: 14
Joined: Wed Sep 07, 2011 2:43 am
Location: Australia

Postby Brian Donahue » Thu May 10, 2012 9:55 am

I checked the source code, and the only condition around scripting the refresh was whether or not the dependencies option was listed.

I'll have to check the command-line parser code.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby Brian Donahue » Thu May 10, 2012 11:12 am

I don't see a problem, so far. And if I use your option set on the command line with verbose on it says include dependencies is set...
SQL Compare running with option: IgnoreFillFactor (OK).
SQL Compare running with option: IgnoreFileGroups (OK).
SQL Compare running with option: IgnoreWhiteSpace (OK).
SQL Compare running with option: IgnoreExtendedProperties (OK).
SQL Compare running with option: IgnoreQuotedIdentifiersAndAnsiNullSettings (OK)
.
SQL Compare running with option: NoTransactions (OK).
SQL Compare running with option: IgnoreUsersPermissionsAndRoleMemberships (OK).
SQL Compare running with option: IgnoreUserProperties (OK).
SQL Compare running with option: IgnorePermissions (OK).
SQL Compare running with option: DoNotOutputCommentHeader (OK).
SQL Compare running with option: IncludeDependencies (OK).
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am


Return to SQL Compare 10

Who is online

Users browsing this forum: No registered users and 1 guest