views:

50

answers:

2

I've recently reached the stage where an ASP.net MVC application I am developing is ready to be deployed to the production server. I've worked out how to publish the application - I've got all the files on the server, and can access them over the internet.

However, I can't work out how to deploy my database. The server has the SQL Server Management Studio Express installed, as the database used is a SQL Server Express database. I have the server instance up and running - I just don't know how to add the tables, etc. to the database.

I have created the "CREATE TABLE" scripts on the development machine, but as far as I can see, Management Studio does not provide any way to actually run these scripts. I have looked through all the menu items that I could see, and none of them worked. Even using the "Create new query..." option and pasting the script in didn't work.

When I try "File->Open..." and select a script to run, set the correct database from the dropdown list on the toolbar, and then execute the script, it complains about not finding the database file (even when I set the USE [...] statement to the correct path.

Deleting the USE [...] statement, the script complains that it can't find the [dbo].[Invoices] object; however, it shouldn't be able to find it, because its trying to create it!

tl;dr: What's the best way to make sure that the database on the production machine matches the database on my development machine?

EDIT: One of the scripts is online here. The output (after the first two lines were deleted) is here.

A: 

Do you just mean schema or all data? If all data, I would do a backup on your dev macine and then restore on your production machine. Also, those kinds of errors like you mention makes me wonder if your scripts are correct. Have you looked through them to ensure that the correct type of script was generated? Did you generate a script for all tables and objects?

Tommy
+2  A: 

The DATE data type was added in SQL Server 2008. Presumably, your production server is only running SQL Server 2005 and this is why you get the "Column, parameter, or variable #2: Cannot find data type date." error.

You'll have to change your data type to DATETIME (which is supported on SQL Server 2005).

Dean Harding
Second this. The script is failing because it cannot create the table...which explains the rest of the errors a_mod is getting.
Tommy
Thanks, you're right. That (along with re-running all the other scripts so that dependencies were resolved) worked well.
a_m0d