Solved

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

Posted on 2011-02-14
4
1,488 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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