I recently updated one of my projects to Visual Studio 2013. The update changed my .dbproj into a .sqlproj to make it compliant with the new SQL project format.
After the conversion, I ran a schema compare against my SQL project and my SQL 2008 production database and it now considers virutally every object to be different. Upon investigation through the schema compare tool, it appears that the difference lies in the fact that every object definition also includes statements for the permissions granted on that object to every role or user.
Thus, the server side looks like this:
CREATE PROC MyCoolProc
BEGIN
--some code
END
GO
GRANT EXECUTE
ON OBJECT MyCoolProc TO MyAwesomeUser
AS [Schema];
GO
and the client side for the same object looks like this:
CREATE PROC MyCoolProc
BEGIN
--some code
END
Why is this? This didn't occur when I ran schema compare using Visual Studio 2010. In addition, I looked through all of the options for SQL compare tool and I could not find one that would "ignore permission statements for objects". Can anyone help?
EDIT
Just to ensure that this is an issue with Visual Studio's SQL Compare tool and not the SQL Server itself, I re-ran the compare in Visual Studio 2010 between my staging and production database and the object definitions do not include the object permissions like they do in Visual Studio 2013.
First, open the SQL Server Database project with visual studio, right-click on it, and choose compare schema as depicted. Then, we will select the source and target databases and provide a connection to those.
To compare database definitions. On the Tools menu, select SQL Server, and then click New Schema Comparison. Alternatively, right-click the TradeDev project in Solution Explorer, and select Schema Compare. The Schema Compare window opens, and Visual Studio automatically assigns it a name such as SqlSchemaCompare1 .
Without the use of third party tools, one way to compare table schemas using native T-SQL is to query the INFORMATION_SCHEMA. COLUMNS metadata and build a custom made procedure or logic that compares two tables. Another way to do this is to use the dynamic management function sys.
It appears that under the options for Visual Studio 2010's SQL compare tool "Schema Compare Options" window, the tab "Object Types" has a checkbox for all of the object types you want to ignore. It has "Extended Properties" and "Permissions" checked by default.
As compared to Visual Studio 2013's SQL compare tool "Schema Compare Options" window whose tab "Object Types" has a checkbox for all of the object types you want to include in the comparison. Under the "Application-scoped" tree node, all object types are checked by default. Unchecking "Extended Properties" and "Permissions" causes this SQL Compare tool to behave exactly like the Visual Studio 2010 compare tool.
This prevents the extraneous permissions and extended properties from being returned by the server as part of each object's definition. Hopefully, this will help someone else who comes across this same issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With