views:

48

answers:

2

I have a number of manually written scripts (.sql) for tables, views and stored procedures that are used from an ASP.NET application. These scripts drop the object and recreates them. I need a way to update the database when the scripts change without deleting the object. For example, when a column is added to an existing table that has rows in it, I would need to update this table with this extra column without losing the rows.

I need a way to "update" the database on a single click (I can hook up the changes using a batch file). Does Visual Studio support this kind of functionality?

+1  A: 

If you get Visual Studio Team System - Database Edition 2008 - which is now bundled with "Developer Edition" for free - it handles that. Visual Studio database projects without that edition really just store the static SQL that you want to track. The Database Edition is capable of determining the 'deltas' between your SQL and what's in a target database, generating that script, and executing against your database. You do get the option of reviewing that generated SQL, but by default it is very safe [it won't run if it thinks that there will be any data lost].

cbkadel
I should also add - with the 2010 release, this is included with "Visual Studio Premium"
cbkadel
+1 :o) The other great thing is that you can have a Development and Deployment configuration set up so you can make sure your scripts do exactly what you want without effecting the live system.
Ardman
cbkadel - Can you point me to an online resource that talks about this in depth? I assume you want me to use the "Schema Compare" tool? The links that marc_s provided is a good start but does not give detailed info
DotnetDude
Overview of latest version: http://www.softpedia.com/get/Programming/Other-Programming-Files/Visual-Studio-Team-System-Database-Edition-GDR.shtmlSchema compare is OK - but if you right click on the project - and select 'deploy' it'll handle it in more of the one-click situation.
cbkadel
A: 

Yes - it's called Database Projects.

You can define a Visual Studio Database Projects, have create and change SQL scripts inside it, and then execute those against a database connection of your choice when you need to.

See this blog post here for a great explanation, or read the whole series that the 4 guys from Rolla wrote.

marc_s