VS2010 Database Compare. How do you create a *.DBSchema extensioned file? - visual-studio-2010

I'd like to take a snapshot of my database, make some changes and then use the db compare functionality to identify the changes, and who knows, maybe even generate scripts to make the change.
I'd like to avoid having to backup the current db and restore it as a separate db just to have a "before" snapshot. I'm guessing I shouldn't have to.
Obsviously, I'm clueless about db projects and am looking to be pointed in the right direction.
ty!

On the machine which you will generate the schemafile, do the following:
Download Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Desktop. Install 32 bit version first, then 64 bit (if your server is 64 bit)
Copy the files in (Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy) to the machine on which you will run VSDBCMD.EXE, ignore the CE files in step 2, you have already installed these in the Compact SQL install above.
Read and understand Command-Line Reference for VSDBCMD.EXE http://msdn.microsoft.com/en-us/library/dd193283.aspx
Generate the dbschema file by running this from the command prompt: VSDBCMD /a:import /cs:"DbConnectionString" /dsp:SQL /ModelFile: outputfilname.dbschema

I'm using VS2010 Premium and I was able to do the following:
In Server Explorer, add a Data Connection to database A and database B
Right click on database A and choose Compare Schema
Pick database B as the Target, set the options/variables, then click OK
I also have SQL Server Developer Edition installed...so maybe that is what adds this functionality.
Not sure why, but this didn't work for a SQL Azure database.

Related

Using Oracle Developer Tools with Source Control for Visual Studio

I'm a bit lost in implmementing/using tfs version control with Oracle products. The project I'm on is using visual studio 2012, tfs 2013, an oracle 11g server, a few copies of Oracle SQL Developer, and a few copies of toad.
I was recently looking for a way to do tfs version control through visual studio using oracle developer tools*. Is this a viable approach?
When tooling around with it, I've been able to create a database project with tables, procs, etc and put this under tfs version control. I've also been able to run these procs against my normal database server. However, I have not been able to put my existing database under version control. I have also not been able to run my code against the visual studio database project.
So can tfs be used with oracle developer tools to provide a version control solution?
Alternatively, are there any ways to integrate tfs version control with both Oracle SQL develoeper and toad?
*Oracle Developer Tools - http://www.oracle.com/technetwork/developer-tools/visual-studio/overview/index-097110.html
On the oracle developer tools promo page it says
"SQL Script Lifecycle with Source Control Integration: Generate SQL
scripts for Oracle schema objects that your .NET application uses,
manage them in an Oracle Database Project, check them into source
control, edit the scripts in the Oracle SQL Editor, and execute them
with a built in SQL*Plus execution engine."
How does this work? Can I automatically generate the scripts each night and check them in or something?
Yes, after you install Oracle Developer Tools for Visual Studio, you can configure your Oracle Data Connections in the Server Explorer, create a new Oracle Database Project, then drag and drop packages or other items from the Server Explorer to your new project. Then, after editing the .sql files that were generated, you can right-click on the .sql files generated and "Run" or "Run on...". Finally, you can also run subsets of each script by right-clicking on a selection and choosing "Run selection".
You still need the discipline to ensure everyone edits packages via source control and not on the database directly.
SSDT database projects in Visual Studio only support SQL Server.
One option is to try Red Gate Source Control for Oracle, a tool developed by the company I work for. This supports both TFS and Subversion. I'd be interested to know if this is something that might work for you.
You can use Toad to integrate Microsoft TFS changes. Please see : http://www.toadworld.com/products/toad-for-oracle/m/media-library/689.aspx

Visual Studio Project that execute an SQL script

I have this question... probably is similar to Executing scripts from a database project in visual studio
but i didn't understand the solution given.
So i made a Database Server 2008 project inside visual studio.
Just one table. When i press DEPLOY the database is created inside SQLServer2008 and the table is created.
Now what if i would like to give the project to someone who has SQLServer and he needs to recreate the database and the table in his computer?..
Apart form executing the query from Visual Studio is there any way to create an executable that automatically "deploy" from outside Visual Studio?..
Thanks,
There are different types of Database projects in Visual Studio. The old ones, which were not so feature rich. The 'Data Dude' ones that came with Visual Studio 2010 Team Database Edition and the most recent iteration that comes with the SQL Server Data Tools. All of these can be installed on top of the standard Visual Studio Professional and don't require additional licenses.
SQL Server Data Tools is the latest, and also the best integrated and most powerful variant of the bunch. It can also be used to compare existing schema's and generate upgrade scripts or automatically upgrade the schema in an existing database for you.
During build, a package will be created that holds all the schema information for your database. You can then use the command line tools provided by the SQL Server data tools or MSDeploy to deploy your compressed schema file to a new or an existing database.
This deployment mechanism can also upgrade existing schema if needed.

Install sql server express database engine only

I am deploying a wpf application that requires sql server 2008 as a prerequisite. As a result I am embedding the sql server installer in my application. When that launches the SQL Server Installation window shows up:
I don't want the user to have to go through out this installation. That program will install SQL Express and many other things like SQL Management Studio.
Is there a place where I can download SQL Express 2008 the database engine only? so that the user will just have to click next, Agree, Ok... etc... without having to make complicated decisions. Or maybe is it possible to install sql server express throughout the command line?
I am including the installer in my application because my application is supposed to be able to be installed without having an interenet connection. Also I cannto seem to find a place where I can download SQL Server express the database engine only.
Go here and download the appropriate version of SQL Express. Then see the How to: Install SQL Server 2008 R2 Using a Configuration File article on MSDN. Note that after you generate the config file for the installation, changing the following keys in the config will probably be of particular interest to you:
; Setup will not display any user interface.
QUIET="False"
; Setup will display progress only without any user interaction.
QUIETSIMPLE="True"
; Automatically accept the license terms
IAcceptSQLServerLicenseTerms="True"

Database in version control using Visual Studio 2010 Professional

I've added a SQL Server 2008 database project to my Visual Studio 2010 Professional Edition solution in the hope that it might allow me to include my database in version control.
I can commit the schema files for each database object into version control, however these schema files all script objects as create rather than alter, so are not good for colleges getting my changes and updating their databases.
Is this a good way to get my database into source control?
And what would the workflow be for actually using it to update databases to a given revision without losing all the data associated with dropping and re-creating all the tables?
Update: on Premium and Ultimate versions, there is a schema compare tool which makes this easy. This does not exist on Professional. Is there any straightforward manual workaround?
I'm not sure if you can do this in VS 2010 Professional, but in VS 2010 Premium, you can do a schema comparison (Data -> Schema Compare -> New Schema Comparison) between your project and database, and update changes in either direction.
When going from project to database, VS generates a script that copies existing data into a temporary table before dropping the existing one.
The database project has a deploy step (which is present in my Professional copy of VS2010) that will generate a sql script with your sql objects in it.
The key thing here is if you r-click the project, properties, goto deploy and change target database settings to a specific database, when you deploy it will generate a change script for that specific database so it matches the objects in the project (and in theory keep existing data etc).
You can get it to either generate a sql script, or directly update the database. Generating a script is probably a better idea :)

Making script to create database skeleton for SQL Server 2008

I'm making Visual Studio setup for my project.
I want it automatically create empty database inside some SQL Server 2008 (Express)
Is there some tool / way to automatic generate such script of my database (sadly my database structure isn't stable yet)
How can I add it to installation process ? I know that I can run programs and scripts during installation but how can I specify SQL Server for my script ?
thank you.
In SSMS, Right-Click on database -> Tasks... -> Generate Scripts....
Suggest you also look at using the Database GDR R2 projects (if using VS 2008) or the built-in database project if using VS 2010.

Resources