Solved

How do you deploy Generated Database Deployment Script (.sql file) that was generated by vsdbcmd.exe

Posted on 2011-02-14
4
1,482 Views
Last Modified: 2012-05-11
I using VSDBCMD to generate an upgrade script
It creates a ModifyScript.sql file that is the changes required to take Existing Database to match the schema of the UpdatedDatabase.dbschema file.

If you open the ModifyScript.sql file is show the script for the changes
But it has :servar lines in it, which when open in SQL Server Management Studio does not know what to do with these lines. So these files don't seem to be intended to run in Management studio.

So questions is:
  How do you deploy this .sql file using VSDBCMD ?

ECHO "Generating Database Deployment Script..."
vsdbcmd.exe /a:Deploy /cs:"Server=.\SQL2008;Integrated Security=true;Pooling=false" /dsp:Sql /script:ModifyScript.sql /model:"UpdatedDatabase.dbschema" /p:TargetDatabase="ExistingDatabse"
PAUSE

Open in new window

GO
:setvar DatabaseName "ExistingDatabse"
:setvar DefaultDataPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008\MSSQL\DATA\"
:setvar DefaultLogPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008\MSSQL\DATA\"

Open in new window

0
Comment
Question by:true_soln
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:chrismc
ID: 34894678
What you are seeing is SQLCMD code.

In SSMS, when in the Query window you should see a Query Menu, in that there is a SQLCMD mode. Select that and see how you get on?

0
 

Author Comment

by:true_soln
ID: 34894863
Yes selecting SQLCMD mode works in Management studio

But how can you run this .sql file from cmd line, so can automate it ?

0
 
LVL 18

Accepted Solution

by:
chrismc earned 500 total points
ID: 34895173
I'm not familiar with it, but it seems to me that you use VSDBCMD to run it as well.

Here is a link with a reference to all the command line options;
http://msdn.microsoft.com/en-us/library/dd193283.aspx

It does seem there are a number of pre-requisites for the server you are deploying this to;
http://msdn.microsoft.com/en-us/library/dd193258.aspx
0
 

Author Comment

by:true_soln
ID: 34900061
I added /dd in to the options for VSDBCMD
And it deployed the changes in to the existing database and created the modifyscript.sql

So that is one way to update the existing schema,

Still just not sure how can execute the modifyscript.sql file from cmd.
If it can be done from management studio, how do you do it from cmd line ?


ECHO "Generating Database Deployment Script..."
vsdbcmd.exe /a:Deploy /dd /cs:"Server=.\SQL2008;Integrated Security=true;Pooling=false" /dsp:Sql /script:ModifyScript.sql /model:"UpdatedDatabase.dbschema" /p:TargetDatabase="ExistingDatabse"
PAUSE

Open in new window

0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question