Solved

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

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

730 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