[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using SQLCMD in Visual Studio to run sql scripts NOT IN a database project

Posted on 2011-09-22
1
Medium Priority
?
603 Views
Last Modified: 2012-12-04
Hi

I am part of a team using Visual Studio/Team Foundation Server to manage database development.

We are using a database project to manage schema changes.

We have a folder in TFS, not in the database project where we keep run-once-only scripts to update metadata/config data. We see no reason in keeping these in the Pre/PostDeployment script area of the database project as these files will not be updated once they have been run.

My question is: is there a way to refer to files in a TFs folder, so that I can create a single deployment script with something like:

:r "$/MyProject/MetaDataScripts/Release1/Script1.sql"
:r "$/MyProject/MetaDataScripts/Release1/Script2.sql"

where the path is refering the source location in TFS Source Control Explorer?

Thanks
0
Comment
Question by:dalsandhu
1 Comment
 
LVL 40

Accepted Solution

by:
lcohan earned 2000 total points
ID: 36581165
As long as all access is in place at folder and SQL database lever for the NT/SQL login(s) that are running the SQL scripts I can't see why not. All you need to provide is the full path to the SQL script file and make sure folder/db access is in place.

http://msdn.microsoft.com/en-us/library/ms170572(v=SQL.100).aspx
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

834 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