All Questions
Tagged with sqlcmd database-project
17 questions
0
votes
1
answer
487
views
Execute many scripts only if condition is met, without breaking IF through GO-statement
In my SSDT Project (Visual Studio Database Project) i have a lot of scripts that must be executed only if a condition is met.
The condition is the servername (@@servername != 'LiveServer').
The ...
0
votes
1
answer
2k
views
Dynamic values to SQLCMD variable: Setvar
I am working with Visual Studio 2017 Database Project (Dacpac) and I have some SQLCMD variables in Publish file (in xml file) like below-
<SqlCmdVariable Include="ClientDBName">
<Value>...
4
votes
1
answer
1k
views
How do you reference a sql script (not procedure) in a Script.PostDeployment.sql in Azure DevOps?
How to get the path to a script (not procedure) in Azure DevOps build?
I'm trying to get the path to either my solution or project file to use in Visual Studio database project PostDeployment.
Works ...
1
vote
2
answers
272
views
Is it possible to get the content of a script file in a database project?
Ok so I have a Visual Studio Database project where I´m trying to do some post deployment stuff (Script.PostDeployment.sql).
What am I trying to do?
What I like to do is to be able to copy the content ...
1
vote
2
answers
3k
views
Access Build variables inside Pre and Post deployment scripts SSDT
I have just set up an SSDT project which I want to use to create local databases on the SQL server hosted locally on my machine.
I want to add some pre- and post- deployment SQL scripts for ...
4
votes
2
answers
7k
views
Can I use SQLCMD Commands in Visual Studio Database Project Stored Procedure?
I have a lot of SQL that is the same over multiple stored procedures.
For example most procedures have the same variables declared, and is in the same try catch block to handle errors.
I'd like to ...
0
votes
1
answer
1k
views
SQL16010: Incorrect syntaxt after using :r on a database project
I have a database project with the following structure
When I try to publish the profile, the VS compiles de code before and is showing me the following error:
SQL46010: Incorrect syntax near .
I ...
1
vote
1
answer
2k
views
How not to include sql file content when publishing?
I have a question that is very similar to an older question of mine Using variable in sql postdeployment build script?
But now I don´t want to do an if/else and have the sql code in my published ...
3
votes
0
answers
285
views
"Fatal scripting error: Command Out is not supported" in PostDeployment Script
In my database project I have Post-Deployment script which looks like this:
:r "..\PostDeployment\InitialScript1.sql"
:r "..\PostDeployment\InitialScript2.sql"
:r "..\PostDeployment\InitialScript3....
1
vote
0
answers
413
views
SQLCMD variable in database project object
In visual studio 2012, I have a database project with the following service broker Route object:
CREATE ROUTE [MyRoute]
WITH
SERVICE_NAME = '[MyService]',
ADDRESS = '$(...
1
vote
0
answers
867
views
Database Project - how can I access SQLCMD Variables in the Post build event command line
I've got a database project that I'm wanting to have call a batch file in the post-build event. So far that's pretty simple, but I want to be able to set some variables in the SQLCMD Variables ...
12
votes
1
answer
11k
views
Using variable in sql postdeployment build script?
What I would like to be able to do, is to be able to create a publising xml script in Visual Studio database project that defines a variable, that will be used to compose a script.
My problem is that ...
1
vote
0
answers
207
views
Visual Studio Database Project; SQLCMD reference all files in a folder
I have a database project with a pre-deployment script in which I reference several sql script and xml files. For example:
:r .\PostDeployment\StaticData.sql
DECLARE @xmlMyFile1 XML =
$(APOS)
:r ..\...
3
votes
1
answer
9k
views
Visual Studio: use SQLCMD variables to change DB types at deploy time
We have a DB project in Visual Studio and it produces a .dacpac file. We then use this dacpac with sqlcommand.exe to deploy our database.
Our requirement is to be able to change column types at ...
1
vote
1
answer
329
views
Database Project - Error with INSERT statement
I am trying to seed my database using a Database Project in Visual Studio 2012. As park of my Post Deployment script I have a statement similar to the following:
INSERT INTO SomeTable (SomeTextCol) ...
64
votes
4
answers
29k
views
How to properly manage database deployment with SSDT and Visual Studio 2012 Database Projects?
I'm in the research phase trying to adopt 2012 Database Projects on an existing small project. I'm a C# developer, not a DBA, so I'm not particularly fluent with best practices. I've been searching ...
6
votes
0
answers
3k
views
Visual Studio Database Deployment - Script not running in SQLCMD mode
I have a SQL Server 2008 Database Project that I'm attempting to deploy using Visual Studio 2010. When I click deploy, the build works fine, but after it creates the deployment script and begins to ...