Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying SQL Server Databases from Test to Live

I wonder how you guys manage deployment of a database between 2 SQL Servers, specifically SQL Server 2005. Now, there is a development and a live one. As this should be part of a buildscript (standard windows batch, even do with current complexity of those scripts, i might switch to PowerShell or so later), Enterprise Manager/Management Studio Express do not count.

Would you just copy the .mdf File and attach it? I am always a bit careful when working with binary data, as this seems to be a compatiblity issue (even though development and live should run the same version of the server at all time).

Or - given the lack of "EXPLAIN CREATE TABLE" in T-SQL - do you do something that exports an existing database into SQL-Scripts which you can run on the target server? If yes, is there a tool that can automatically dump a given Database into SQL Queries and that runs off the command line? (Again, Enterprise Manager/Management Studio Express do not count).

And lastly - given the fact that the live database already contains data, the deployment may not involve creating all tables but rather checking the difference in structure and ALTER TABLE the live ones instead, which may also need data verification/conversion when existing fields change.

Now, i hear a lot of great stuff about the Red Gate products, but for hobby projects, the price is a bit steep.

So, what are you using to automatically deploy SQL Server Databases from Test to Live?

like image 615
Michael Stum Avatar asked Aug 02 '08 23:08

Michael Stum


People also ask

Can I host an SQL database locally?

It's possible. And you don't need to download any other software. Fire up XAMPP and start the Apache and MySQL servers then go to your browser and enter http://localhost/phpmyadmin.

Can you use SQL to automate?

SQL queries are very powerful by themselves, but by automating queries as part of your data flow, you will unlock tons of potential in your data. In this use case, we will explore using the SQL Runner App to automate, insert and update queries. Continue reading to learn how.


1 Answers

I've taken to hand-coding all of my DDL (creates/alter/delete) statements, adding them to my .sln as text files, and using normal versioning (using subversion, but any revision control should work). This way, I not only get the benefit of versioning, but updating live from dev/stage is the same process for code and database - tags, branches and so on work all the same.

Otherwise, I agree redgate is expensive if you don't have a company buying it for you. If you can get a company to buy it for you though, it really is worth it!

like image 106
Karl Seguin Avatar answered Oct 08 '22 17:10

Karl Seguin