Solved

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

Posted on 2011-09-22
1
525 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 39

Accepted Solution

by:
lcohan earned 500 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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

895 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

16 Experts available now in Live!

Get 1:1 Help Now