Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-14
4
Medium Priority
?
1,498 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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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