Solved

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

Posted on 2011-02-14
4
1,477 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this article I will describe the Backup & Restore 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.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now