Sql Server 2008 Database Project Delta Deployment - visual-studio-2010

I have created a new Sql 2008 Database Project in Visual Studio 2010. I imported the database objects and only kept the stored procedures. That all worked as expected. Where I have the problem is that it tries to deploy the entire set of procedures each time. I expect it to only create the deployment script for the delta. I am pretty sure that I combed every setting, but I can't find it. So if someone could first validate that this is possible and second tell me where to look. I need to do this because we only deploy the stored procedures with each release, the database schema is not modified.

Do a Schema compare of the project (as source) with the database where you want to deploy (as target). Once shcem comparison results are shown you have a choice to select which changes you want to deploy and then click the button "Export to T-SQL Editor". It will create the delta script.

Related

Oracle Developer Tools for Visual Studio 2017 (ODT)

I have created an Oracle Database Project Version 2 on visual studio 2017 and imported an existing database to the project to obtain the database schema on my project, and I got an SQLfile for such object in my project. The problem is when I'm modifying a table for example and saving the changes on my oracle database project and build it, I get a create script as output instead of an alter script so this script can't be deployed to my database due to "existing object error".
I tried to do it otherwise by proceeding to schema compare option:
I launched the schema comparison by mentionning my oracle database project as source and my database as target
The result of the comparison indicated that there is an non indentical object between the source and the target which was the table (because i added a coloumn to the table)
Again the problem is when I generate the update script it gives a drop/create table script instead of an alter and I can't deploy this script because I will lose data.
Does anyone have any ideas? how can I get the alter script by building the project or launching a schema compare operation?
I've found that comparing two databases DO generate a "somewhat" correct diff script (it may need some manual adjustment). So you can run the SQL file generated by the database project against a different oracle instance, and then compare both.

SQL Server Database Project not handling new script file creation correctly

When using a SQL Server Database Project in Visual Studio, if you have more than 1000 stored procedures in a database, when you import it Visual Studio will split the procedures into separate directories.
When you attempt to sync any new stored procedures into the project following such an import, via the 'Schema Compare' function, Visual Studio forgets this split folder structure and places all new scripts directly into the 'Stored Procedures' folder. This means that new stored procedures which are scripted do not fit into the existing structure, which forces the user to either live with this detached structure or to manually update project references and copy the files back into the initial structure which Visual Studio created.
Steps
Create a new SQL project.
Right click on the project in solution explorer > select 'Import' > 'Database'.
Bind the project to a SQL2008 database which has more than 1000 stored
procedures. Select 1000 for 'Maximum files per folder'.
Allow VS to script out all of the stored procedures. It will automatically
break into batches of 1000 and create a new folder 'Proc1', 'Proc2'
for each batch as necessary.
Open a new comparison by right clicking on the SQL project > select 'Schema Compare'.
Verify the database synced correctly by comparing the SQL project to your
original database. There should be no pending changes.
Create a new stored procedure in the database which was synced.
Run the comparison again, this should now show the new stored procedure
under the 'Add' type.
Click 'Update' and allow VS to create a script for the new procedure.
Instead of placing the new script in the original 1000 delimited folder structure, it will instead place the new script in the 'Stored Procedures' folder directly.
That is an interesting scenario. I will check it out one of these days.
Here is my 2 cents. After the initial load of all the database objects into a database project I(or dev team) stop the practice of adding new SPs or any objects directly to the database through SSMS. Instead, I add them to the Database Project and deploy to all the servers I need them to go to. The database project acts like the true source of code from that point on-wards. On top of that, you can leverage TFS branching feature to keep QA version, Prod version of the Database Projects. I also try to give meaningful names to the folders to categories the SPs under the Stored Proc folder which helps in my future code maintenance.

How to run script generated by publish for SQL Data project

I'm using SSDT (in SQL Data Project) in Visual Studio 2013. When I publish the database, I can
Do a direct publish (click the publish button)
Generate the script, then execute in Visual Studio
But the script does pretty much nothing (apparently) if I copy it to SSMS and try to execute it (in SQLCMD mode).
How would I execute a generated script outside of Visual Studio? Do I have to use sqlcmd.exe? And if so, are there certain command line parameters that I would need to use?
Thanks!
The comment by Peter helped me look at the issue from a new angle. It wasn't a database problem, but a table issue. The database has an auditing table for every table. I was updating the Address table (I thought), but instead updated the A_Address table. It was all working fine. The first run updated the audit table, subsequent runs didn't (of course), but I was checking the Address table for the update. Doh! New database, new technology....

How do I deploy specific objects from a Visual Studio database project?

I have a Visual Studio 2010 database project and I'd like to do a partial deployment, i.e. of specified objects. Is this possible? The only options I can see are to either do a full deployment or stop after generating the script.
For example, I'm changing many tables and stored procs but not everything is 100% finished and I'd like to push out a specific stored procedure to my test database, including its permissions, etc.
I read a little bit about SQL Server Data Tools, which apparently supports this, but I'm not clear on whether I'd have to migrate my database project to use that instead (would also need the ok from team lead), or if it's simply a plugin that would allow extra functionality.
Check out Schema Comparisons. They allow you to select the objects you want to deploy. They are available without SQL Server Data Tools.
A "partial deployment" is actually a little dangerous. Consider that you will have just built your database project, your entire database project, complete with the table changes, and it has built with no errors or warnings (right?). Now you want to deploy just your stored procedure, into a database that does not have the table changes.
Your stored procedure got no errors or warnings in the context of all the changes. Are you sure it will get no errors or warnings without those changes?
You should consider a source control solution to this problem. Save a copy of your stored procedure, revert to a version of the code that matches the database you'll be deploying to, then make your stored procedure changes to that. When you deploy, you will be checking to see if the stored procedure makes sense in the context of the database you'll be deploying into.

Visual Studio 2010 SQL Database Project Command-Line Schema Compare

I use SQL 2008 Database Project to keep track of all my database changes and easilly update databases by running schema compares on them.
A bad thing is that I need to have VS2010 on the machine I want to perform the schema compare.
Currently I've been able to open a door on the remote servers and connect to them, executing the schema comprare on my machine but it would be great if I could execute everything right on the destination server.
Is there a way to perform a schema compare using nothing but the generated DB Project schemas?
I'm not sure why is it a bad thing that you have SQL2008 databases and work with VS2010. I do it every day. But if you just want to compare two DB schemas (meaning .dbschema files).here is an article on how to do it: http://msdn.microsoft.com/en-us/library/aa833435.aspx#comparewithvsdbcmd

Resources