Reputation: 71131
What is the best way to develop on SQL Server 2005 machine locally while you get your database design and application design smoothed out and then deploy to a shared host?
In the MySQL / phpMyAdmin world you have an option to export the table as the DDL Statement with the data represented as a bunch of inserts following the DDL. Using this you can drop a table, recreate it, and load it with data all from a query window.
Is there anything close to this in the Microsoft world? Is there any free/open source tools to help with this migration of data?
Upvotes: 1
Views: 482
Reputation:
You can also choose a shared hosting company that provides a tool like myLittleBackup (www.mylittlebackup.com) so that you can easily install/restore your db on the shared server.
Upvotes: 0
Reputation: 43168
SQL Server Management Studio Express (which is free) includes the "Generate Scripts" option that TheTXI referred to.
The Database Publication Wizard is a more lightweight product (also free) that is specifically for generating export scripts for both schema and data.
Caveat — neither is 100% reliable. I've sometimes had to tinker with the scripts to get them to run, particularly regarding the order of dependent objects. It's a pain, but still better than starting from scratch.
As RedBeard mentioned, you should be keeping track of your DDL scripts, in particular the "diff" scripts that will upgrade you from one revision of the database to the next. In that case, these tools would not be useful during the normal development cycle. However, if you haven't been managing your scripts this way, these tools can help you get started, and are also good for creating new instances, migrating instances, comparing snapshots, and a host of other things.
Upvotes: 2
Reputation: 11231
A couple of options:
You have a set of scripts that can be executed to create or update your database. You could actually pull DDL statements from your SQL Server database itself. Look in the INFORMATION_SCHEMA system views.
Example, to get information about stored procedures and their definitions, look at the ROUTINE_DEFINITION field (keep in mind you'll find some other procedures that you didn't define, but come built-in to sql server):
SELECT SPECIFIC_SCHEMA,SPECIFIC_CATALOG, SPECIFIC_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
Basically it does the above for you and streamlines the setup and revision control of your database. It allows you to define data and structure, has a lot of Unit testing features as well.
Backup your local database, upload it to your host, restore the database there.
Similar to the backup/restore, you need to detach your database, copy or move the files to your web host and then reattach there.
There should be a few examples of how this is done. It treats the database as a file, but it does require a SQL Server engine to be installed on the web host.
As an example, taken from an ASP.NET MVC template (web.config):
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
Upvotes: 1
Reputation: 61242
TheTXI's solution is good. Making a backup and restoring it also works, and is sometimes (depending on the ISP/host's lockdown of MS SQL) the only option.
Upvotes: 0
Reputation: 37905
Generate Scripts of all your database schema (tables, stored procedures, views, etc.) and also do exports of your data (if necessary) and then run those scripts and import the data into your shared host. Depending on that host, you could get access through Management Studio and it would be an even easier process.
Upvotes: 1