sql-server-data-tools

How to develop t-sql in Visual Studio?

房东的猫 提交于 2019-12-03 21:39:59
We are using Visual Studio 2013 with SSDT mainly for versioning t-sql code, so the sql is being developed on the dev server and then we use schema compare to transfer the scripts into visual studio (and check into Git). Before deployment (which we currently do with schema compare, too) we have to replace database and server references (with [$(database)] etc.). If we change the code in the dev server and compare again, such SQLCMD variables are lost again. (I would expect schema compare to be smart enough to retain the SQLCMD variables but I found no way to accomplish this). The logical step

SSDT creating a rollback deployment script?

不问归期 提交于 2019-12-03 17:18:51
we can create a SQLServer deployment script with TFS&SSDT, but is there a way to create a rollback script, so that we can roll back the deployment? Thank's As SSDT (and similar products) all work by comparing the schema in the project against a live database to bring the database in sync with the model, there's not a direct way to create a rollback script. There are also considerations regarding data changed/added/removed through pre or post-deploy scripts. That being said, there are a handful of options. Take a snapshot each time you do a release. You can use that snapshot from the prior

how to use msbuild properties in sqlproj (SQL Server 2012) script

佐手、 提交于 2019-12-03 13:24:12
I just upgraded my existing SQL Server 2008 r2 .dbproj to a SQL Server 2012 .sqlproj (using SQL Server Data Tools). Previously, I was able to define a SQLCMD variable in my project, and then define the value by editing the project file to use msbuild values by adding the following element: <ItemGroup> <SqlCommandVariableOverride Include="ProjectDirectory=$(MSBuildProjectDirectory)" /> </ItemGroup> Which I could then use in my PostDeployment script like this: SELECT * INTO dbo.MyTable FROM dbo.MyTable WHERE 1=2 BULK INSERT dbo.MyTable FROM '$(ProjectDirectory)\data\dbo.MyTable.dat' WITH

TSQL Unit Test tools 2017: SQL Server Data Tools 2017 vs tSQLt

耗尽温柔 提交于 2019-12-03 12:23:15
I have a new project that needs SQL Server unit test, and CI/CD with VSTS. Below is the features that are required SQL server unit test against stored procedure, initial target tables setup for each test and clean up Unit test in sql CI/CD with VSTS and Git Easy setup and easy to use I looked into SSDT 2017, which seems good. But it seems it lacks a feature where common setup script can be shared easily between each test in Pre-Test step. It might lack other features that should be available for daily usage. But I might be wrong. Which tool fits better for general sql server unit testing in

SSDT SQL Server Debugging Doesn't Hit CLR Breakpoints

时光总嘲笑我的痴心妄想 提交于 2019-12-03 12:21:55
问题 I applied the SQL Server Data Tools patch to Visual Studio 2012 (Premium) and created a SQL Server CLR user-defined function project in C#: public partial class UserDefinedFunctions { [Microsoft.SqlServer.Server.SqlFunction] public static SqlInt32 Add42(SqlInt32 in_param) { SqlInt32 retval = in_param + 42; // Set break point here. return retval; } } In the SQL Server Object Explorer pane, I right-click on the newly published UDF and select "Execute Function..." I am prompted to supply a

Default to the T-SQL Pane view within Visual Studio 2012 Database Project

戏子无情 提交于 2019-12-03 11:02:59
问题 When working with a Database Project in Visual Studio 2012, VS defaults to the "Design-View" pane when you add or edit a table. While you can work in split-screen mode, the T-SQL pane defaults to the bottom pane. As I prefer to work with T-SQL directly as opposed to the designer, I constantly am switching to make the T-SQL pane the top-most editor in order to work with the object. Unfortunately, VS does not remember this preference, so each and every time I work with a table I must change to

Hosted VS2017 agent build master.dacpac does not exist

倾然丶 夕夏残阳落幕 提交于 2019-12-03 10:52:24
问题 My solution created with VS2017 Professional contains an SQL Server Database Project that references the master database. When using the Hosted VS2017 agent to build my solution in Visual Studio Team Services I'm getting the errors below: 2017-07-14T12:44:17.8387743Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets(559,5): Error SQL72027: File "C:\Program Files (x86)\Microsoft Visual

SSDT project builds much slower with MSBuild than in VS 2013

主宰稳场 提交于 2019-12-03 09:32:31
I noticed that our SSDT projects were building much slower via TFS build definitions than via VS 2013 on my local dev box. On the build server itself, I can build our largest SSDT project via VS 2013 in about 2 minutes. The exact same project builds from the command line on the same server using MSBuild in about 16 minutes (i.e. building in the same way TFS build definitions build SSDT projects) I've gathered /verbosity:diagnostic output from both methods, but cannot for the life of me see any material difference in the parameters being supplied to MSBuild. In VS 2013, the configuration was

Import Database in VS 2015 SQL Server Database Project

让人想犯罪 __ 提交于 2019-12-03 06:40:31
问题 I recently had troubles Importing a Database from a SQL Server Database Project in VS 2015. Just hoping this helps some folks. I will add more pictures when my rep is higher. Error I get: The server version or database compatibility level is not supported. This is the Error I get when I right click on the project and try and Import a Database . Import Error: 回答1: Right click on the Project and clicking View in Object Explorer . Add and connect to your database next, if needed. Right click on

Hosted VS2017 agent build master.dacpac does not exist

淺唱寂寞╮ 提交于 2019-12-03 04:40:19
My solution created with VS2017 Professional contains an SQL Server Database Project that references the master database. When using the Hosted VS2017 agent to build my solution in Visual Studio Team Services I'm getting the errors below: 2017-07-14T12:44:17.8387743Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets(559,5): Error SQL72027: File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\SQLDB\Extensions\SqlServer\110\SqlSchemas