Database Administrators
Q&A for database professionals who wish to improve their database skills
Latest Questions
34
votes
2
answers
28356
views
Why is :r SQLCMD command marked as wrong in Post Deployment Script?
I have worked a couple of times with post deployment scripts and always, intuitively used the build action "PostDeploy", because that is what it is. Now for the first time I try to follow the built-in instruction from the script's template to use the `":r somescript.sql"` syntax. Immediately this li...
I have worked a couple of times with post deployment scripts and always, intuitively used the build action "PostDeploy", because that is what it is.
Now for the first time I try to follow the built-in instruction from the script's template to use the
":r somescript.sql"
syntax.
Immediately this line is getting marked as wrong:
> "SQL80001 wrong syntax next to ':'"
I found suggestions to set the PDS to Build Action "none". This does not help, the error stays. What am I missing here?
Magier
(4827 rep)
Sep 7, 2015, 07:58 AM
• Last activity: Jan 17, 2023, 12:45 PM
5
votes
4
answers
17286
views
Script component source won't load when click "Edit Script..."
I'm working on an SSIS package in Visual Studio 2013. For any script component throughout the package, if I double-click on it and then click the "Edit Script..." button, Visual Studio 2012 opens but no editor window loads. It's just an empty window like you closed all documents. The Solution Explor...
I'm working on an SSIS package in Visual Studio 2013. For any script component throughout the package, if I double-click on it and then click the "Edit Script..." button, Visual Studio 2012 opens but no editor window loads. It's just an empty window like you closed all documents. The Solution Explorer shows items, but notably "ScriptComponent" is an empty folder:
If I try to open any of the files (BufferWrapper.cs, ComponentWrapper.cs, main.cs) in the Solution Explorer, I get a popup error box saying:
Anyone have any clue what's going on here? FWIW, I have tried closing all instances of Visual Studio and reopening my solution with the SSIS package. The same behavior persists.


Chris Pratt
(311 rep)
Sep 15, 2015, 04:02 PM
• Last activity: May 25, 2021, 04:03 PM
2
votes
1
answers
173
views
How to cope with SQL Server 2012 vs SQL (Azure) Database sql files
I'm trying to port my system to SQL Database (Azure instance) from SQL Server 2012. I'm using Visual Studio 2013 and I have my .sqlproj with all the definition of my database inside. Given that a number of SQL statements are not available in SQL Database (like "ON [PRIMARY]", filegroups, etc.), I sh...
I'm trying to port my system to SQL Database (Azure instance) from SQL Server 2012. I'm using Visual Studio 2013 and I have my .sqlproj with all the definition of my database inside.
Given that a number of SQL statements are not available in SQL Database (like "ON [PRIMARY]", filegroups, etc.), I should change a huge number of *.index.sql , *.pkey.sql, *.table.sql files. Unfortunately I still need to cope with SQL Server 2012 installations (some customers are still on that infrastructure), so I would like to have instead a simple way to switch between the "SQLAzure" vs. "OLD-2012" syntax.
E.g. something like Compilation Symbols would be useful, or similar tricks.
Anyone has a brilliant idea on how to manage such an issue?
Thank you very much!
cghersi
Cristiano Ghersi
(221 rep)
Aug 11, 2014, 11:41 PM
• Last activity: Nov 12, 2020, 06:02 AM
3
votes
2
answers
5521
views
SSIS: script task on Visual studio 2013 can not open since Visual Studio 2015 was installed
Until the installation of Visual studio 2015, it was always opening Visual studio 2012. Attached the only error he throws, It seems he was trying to open Visual Studio 2015. [![enter image description here][1]][1] [1]: https://i.sstatic.net/e87kJ.png
Until the installation of Visual studio 2015, it was always opening Visual studio 2012.
Attached the only error he throws, It seems he was trying to open Visual Studio 2015.

Refael
(239 rep)
Jan 20, 2016, 11:59 AM
• Last activity: Jul 18, 2019, 12:59 PM
1
votes
1
answers
2618
views
Unable to find "Local" window while debugging SSIS package
I'm trying to debug my package in SSIS. I need to see the value of my variables while debugging, but the problem is that I cannot find the "Local" window. The only window I have is the breakpoint window as you can see below: [![enter image description here][1]][1] [1]: https://i.sstatic.net/bcafW.pn...
I'm trying to debug my package in SSIS. I need to see the value of my variables while debugging, but the problem is that I cannot find the "Local" window. The only window I have is the breakpoint window as you can see below:
What is wrong with my Visual Studio? (I'm using Visual Studio 2013)

user157749
Oct 6, 2018, 07:41 AM
• Last activity: Oct 10, 2018, 05:37 PM
3
votes
3
answers
4350
views
Visual Studio database project and Enity Framework code-first
At work we are developing our latest module in C# Entity framework code-first approach. I have been given the role of developing databases from the DBContexts from within the project/s. I generated the tables/entities from the DBContext and created database projects and all is fine. My question is:...
At work we are developing our latest module in C# Entity framework code-first approach. I have been given the role of developing databases from the DBContexts from within the project/s.
I generated the tables/entities from the DBContext and created database projects and all is fine.
My question is: When a developer changes the DBContext entities or changes a property of an entity, how can I become aware of such changes and update the database projects?
Guygar
(131 rep)
Jan 23, 2017, 11:08 AM
• Last activity: Aug 30, 2018, 05:00 PM
2
votes
1
answers
1474
views
How to Publish Checked-In changes only in Team Foundation Server 2013 to SQL Server?
I would like to ask you how to publish checked-in changes only in Team Foundation Server 2013 to SQL Server? It's a new installation of TFS 2013 - installed by me. Currently when I create new object like table as a part of the project and don't do check-in on this table and next publish the project,...
I would like to ask you how to publish checked-in changes only in Team Foundation Server 2013 to SQL Server? It's a new installation of TFS 2013 - installed by me.
Currently when I create new object like table as a part of the project and don't do check-in on this table and next publish the project, such table is published anyway. I was thinking that only checked-in (approved) changes are published to SQL Server (without objects which has no approval).
It's important because I want publish only complete objects to the SQL Server. Without objects which are still in development.
Tomasz Wieczorkowski
(362 rep)
Nov 1, 2015, 10:20 PM
• Last activity: Jun 29, 2018, 11:40 PM
0
votes
1
answers
565
views
Visual Studio 2013 and up - Database Project Schema Compare File
Is there any reason to save the schema compare file once you are done comparing, creating scripts or just simply updating?
Is there any reason to save the schema compare file once you are done comparing, creating scripts or just simply updating?
Moojjoo
(103 rep)
Jun 14, 2016, 03:17 PM
• Last activity: Apr 21, 2018, 06:23 PM
0
votes
1
answers
85
views
Procedure returning different values
I have a procedure `TempSalesUpdateID` which gets all ProductName's column in TempSales table and set it's corresponding ProductID. ALTER PROCEDURE [dbo].[TempSalesUpdateID] AS UPDATE T SET T.ProductID = P.ProductID FROM TempSales T INNER JOIN Products P ON P.PN=T.ProductName When I execute it throu...
I have a procedure
TempSalesUpdateID
which gets all ProductName's column in TempSales table and set it's corresponding ProductID.
ALTER PROCEDURE [dbo].[TempSalesUpdateID]
AS
UPDATE T
SET T.ProductID = P.ProductID
FROM TempSales T
INNER JOIN Products P
ON P.PN=T.ProductName
When I execute it through SQL Server Management Studio it runs perfectly: when it finds a corresponding ID, it fills ProductID column, otherwise leaves it NULL.
When I run it from my C# Windows Form Application, it puts almost random numbers instead of leaving NULL (the ones which doesn't have a corresponding ID).
I say almost because: 13098 rows have value 1 instead of NULL, 14742 rows have value 2 instead of NULL, 13601 value 3, etc.
Could you please help me? I'm really lost here
G. Knoxx
(15 rep)
Mar 10, 2017, 05:20 PM
• Last activity: Mar 14, 2017, 01:53 PM
1
votes
1
answers
1573
views
SSDT - Unresolved Reference to temporary table in linked server
Here's the scenario. I am extracting data from a table in an Oracle database via a linked server as part of an ETL process. I am developing the solution in Visual Studio 2013 with SQL Server Data Tools (SSDT). The ETL procedure uses a temporary table which is dynamically created in the Oracle databa...
Here's the scenario.
I am extracting data from a table in an Oracle database via a linked server as part of an ETL process. I am developing the solution in Visual Studio 2013 with SQL Server Data Tools (SSDT).
The ETL procedure uses a temporary table which is dynamically created in the Oracle database via EXECUTE AT syntax. This is so that I can insert a small number of records from my SQL Server database into the temporary table in order to perform a join to a much larger source table (~20m rows) in the Oracle database. The insert statement uses four-part naming as follows:
INSERT INTO [linked-server]..[owner-name].[table-name]
SELECT a, b FROM [stage].[table-name];
However, because the table is temporary, my project contains a warning about an unresolved reference:
> SQL71562: Procedure: [schema].[procedure-name] has an unresolved
> reference to object [linked-server].[].[owner-name].[table-name]
Also, when I publish the database project, the publish operation fails because the temporary table does not exist. The error message reads:
> The OLE DB provider "OraOLEDB.Oracle" for linked server
> "[linked-server]" does not contain the table
> ""[owner-name]"."[table-name]"". The table either does not exist or
> the current user does not have permissions on that table.
I *can* publish the project by creating the temporary table first via SQL Management Studio then dropping it after the project has been published. But this seems to go against how database projects should work.
I've seen suggestions about suppressing T-SQL warnings for unresolved references, but that doesn't enable me to publish the project.
Notes:
1. The Oracle database belongs to a 3rd party application so I cannot
create permanent tables in the database
2. I have created the linked server object in the SSDT project
Jazza
(113 rep)
Apr 22, 2016, 08:23 AM
• Last activity: Jan 8, 2017, 02:27 AM
1
votes
1
answers
3778
views
The application is not installed - Visual Studio 2013
I need to deploy packages using visual studio 2013 but I am seen this message, the application is not installed, as you can see on the picture below. what do I need to install? [![enter image description here][1]][1] [1]: https://i.sstatic.net/zlCnq.jpg
I need to deploy packages using visual studio 2013 but I am seen this message, the application is not installed, as you can see on the picture below.
what do I need to install?

Marcello Miorelli
(17274 rep)
Aug 18, 2015, 11:00 AM
• Last activity: Oct 6, 2016, 04:20 PM
2
votes
2
answers
11450
views
Data Flow Transform Not Automatically Mapping Columns
I'm in the midst of creating a set of SSIS 2014 packages (using Visual Studio 2013) importing data from 50 tables. Since most of the tables are being filtered on the same column and I'm importing all columns into my staging area, I opted for a reusable design where my package name matches the table...
I'm in the midst of creating a set of SSIS 2014 packages (using Visual Studio 2013) importing data from 50 tables. Since most of the tables are being filtered on the same column and I'm importing all columns into my staging area, I opted for a reusable design where my package name matches the table name, my OLE DB source query is defined with an expression-based variable (starting with
SELECT * FROM ...
) and my OLE DB destination table is also defined with an expression-based variable (in this case *schema.tablename*).
Both the source query and target table have matching column names and match in most cases on data types and sizes.
As I'm cloning my packages for each table, I copy/paste a previously-created package and visually inspect the mappings to confirm the expressions and the data flow mappings are valid for the new package name. I'm seeing that the expressions are working as planned, but I have to manually do the drag/drop mapping of most columns in the destination editor.
Is this expected behavior of the editor as the design metadata of the original package is invalid under the new package name and is there a way to have Visual Studio delete and remap all columns in the data flow based on column name?
MattyZDBA
(1955 rep)
Sep 29, 2015, 10:07 PM
• Last activity: Jul 16, 2016, 07:31 PM
1
votes
0
answers
76
views
SSIS DTSPackageType behaviour
I created a new SSIS package within Visual Studio 2013 with SSDT BI Tools (12.04.2430.0) installed bu when looking into this package I can see that the DTSPackageType is set to DTSDesigner100. Based on [this documentation](https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtsp...
I created a new SSIS package within Visual Studio 2013 with SSDT BI Tools (12.04.2430.0) installed bu when looking into this package I can see that the DTSPackageType is set to DTSDesigner100. Based on [this documentation](https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtspackagetype.aspx) that means it was created in SSIS Designer in SQL Server 2008!!
I would have expected that the package was created with SSDT for SQL Server 2012
Did I miss a setting or what is the logic behind this behaviour?
nojetlag
(2927 rep)
Nov 20, 2015, 07:48 AM
• Last activity: Nov 20, 2015, 08:24 AM
2
votes
0
answers
885
views
SSDT sqlpackage.exe CreateNewDatabase Parameter Not Respected
Originally asked this on SO but that question seems to be populated only by tumbleweed so wondered if this might be a better forum for it. I have a VS2103 solution which includes a database project for which we have a number of publish profiles. One of these is for the purposes of testing some funct...
Originally asked this on SO but that question seems to be populated only by tumbleweed so wondered if this might be a better forum for it.
I have a VS2103 solution which includes a database project for which we have a number of publish profiles. One of these is for the purposes of testing some functionality that requires an actual database to be in place so it is supposed to publish the database to (localDb), add any lookup data and then run some post deployment scripts to add some fake data.
The test project has a pair of pre-build events to try and ensure that the DB project has been built and is then deployed:
"$(MSBuildBinPath)\msbuild.exe" "$(SolutionDir)CUIA Database\CUIA Database.sqlproj" /t:Rebuild
"$(PROGRAMFILES)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\sqlpackage.exe" /Action:Publish /SourceFile:"$(SolutionDir)CUIA Database\$(OutDir)CUIAWorkspace.dacpac" /Profile:"$(SolutionDir)CUIA Database\UNIT-TEST.publish.xml" /Variables:test_run="True" /p:CreateNewDatabase="True"
The SQLCMD variable is what determines if the test data is inserted into the newly created database, and is defaulted to False.
The problem is that it does not seem to work every time and I cannot find a reason why. If I start with nothing on the local db instance, then it works as expected, the DB is created and the tests have something to use. However, if I then change some of the test data using SSMS and re-run the tests, it seems to be a crapshoot as to whether or not the DB is recreated and mostly it is not. I can see this because my amended test data is still there so it has not been dropped. I have also verified the same behavious on a SQL Express instance. Database logs show no problems and the build outputs from successful runs are the same as for those where the DB is not re-created.
I haven't been able to find much in the way of information on what I am trying to achieve so I'm have to go with some hunches and guesswork so I appreciate that my pre-build event idea is possibly not the best solution. If anyone knows a better one then please speak up and share. However, the primary concern is why is the /p:CreateNewDatabase="True" flag not being respected? Surely this should demand that the database is dropped and re-created every single time?
Steve Pettifer
(441 rep)
Jun 25, 2015, 07:15 AM
• Last activity: Nov 12, 2015, 08:02 PM
2
votes
1
answers
2145
views
How To Merge Database Projects on Visual Studio 2013
Can I have multiple database projects to the same SQL Server database? Like, one main project referencing multiple subprojects. I have an application with multiple modules and each module has its own database structure living in a schema. I want to reuse the modules in another application, for examp...
Can I have multiple database projects to the same SQL Server database? Like, one main project referencing multiple subprojects.
I have an application with multiple modules and each module has its own database structure living in a schema.
I want to reuse the modules in another application, for example, the security module, which has the user, roles, groups, etc.
I want to know if there is a way I can define those schemas and all of its objects (tables, stored procedures, indexes, views, etc) in one database project and then reference this "base" database project in the database project of the actual application.
sergiogarciadev
(123 rep)
Aug 27, 2014, 07:23 PM
• Last activity: Oct 9, 2015, 08:37 PM
3
votes
1
answers
1733
views
How to manage stored procedure dependencies in SSDT?
I have multiple stored procedures, some that depend upon others. When publishing my database, I receive an error when creating some stored procedures due to dependency issues. SSDT seems to be creating the stored procedures in alphabetical order, not dependency order like I need. For example, suppos...
I have multiple stored procedures, some that depend upon others. When publishing my database, I receive an error when creating some stored procedures due to dependency issues. SSDT seems to be creating the stored procedures in alphabetical order, not dependency order like I need.
For example, suppose sp_ProcA depends upon sp_ProcB. SSDT is trying to create sp_ProcA first and fails because sp_ProcB hasn't been created yet.
I've looked through project and script settings. I've found nothing related to dependency management.
mw007
(133 rep)
Sep 29, 2015, 12:04 PM
• Last activity: Sep 29, 2015, 04:44 PM
1
votes
1
answers
783
views
Cannot login to SQL Server from Visual Studio, same credentials work on SSRS page
I am running into a strange issue. I have a SQL Server login that I use for running reports on SSRS. When I go to the SSRS page I can modify the stored credentials to use that login: ![enter image description here][1] Now when I try to build that same login right into the report in Visual Studio I g...
I am running into a strange issue. I have a SQL Server login that I use for running reports on SSRS. When I go to the SSRS page I can modify the stored credentials to use that login:
Now when I try to build that same login right into the report in Visual Studio I get the following error:
I am not sure why I can login from one place but not the other. I am using SQL Server 2014 Standard and VS 2013. Does anyone know what permissions setting needs to be change, or what to do to be able to deploy my report using this?


JamesTheDev
(155 rep)
Nov 13, 2014, 05:38 PM
• Last activity: Aug 15, 2015, 05:27 AM
2
votes
1
answers
604
views
Migrating Oracle 9i database to MySql database on a different Windows Server
I need to migrate my Oracle 9i database with all its tables from windows server 2003 to MySql on another Windows Server 2012. The oracle database is connected to Visual Studio web project. I have successfully imported the files (.aspx) to Microsoft Visual Studio 2013 Community edition. (**Mind that...
I need to migrate my Oracle 9i database with all its tables from windows server 2003 to MySql on another Windows Server 2012. The oracle database is connected to Visual Studio web project. I have successfully imported the files (.aspx) to Microsoft Visual Studio 2013 Community edition.
(**Mind that I need to keep original database intact for few weeks of testing peroid, simply the migration should be , creating a clone copy and not moving the database.**)
I am facing problems as the visual studio project has code for connection with old oracle database. I need to recreate the functioning website.
The only thing remaining is migrating that old database to new server.
I tried SQLWays . ***But It does that on single machine not from another server.***
**Please suggest solutions for migration between different servers.**
Further, what needs to be changed in my vb code even if I migrated the database successfully to get it working with visual studio 2013 project.
(***or may I ask a different question for that?***)
BioDeveloper
(121 rep)
Jul 2, 2015, 12:40 PM
• Last activity: Jul 4, 2015, 10:22 AM
1
votes
0
answers
205
views
TDE state is changed after DB deployment
I have database projects in Visual Studio 2013 from which I deploying databases to SQL Server. Also I am using Transparent Data Encryption for these databases and it is in state 3 which means TDE is ON. Issue becoming when I deploy databases. After database deployment TDE state is 1 which means TDE...
I have database projects in Visual Studio 2013 from which I deploying databases to SQL Server. Also I am using Transparent Data Encryption for these databases and it is in state 3 which means TDE is ON.
Issue becoming when I deploy databases. After database deployment TDE state is 1 which means TDE is OFF. I only know that Database Encryption Key exist in database page level and I supposed that something happened there when DB schema is changed.
My question is how I can control that process? How I can save TDE state to be 3 after deployment?
I can run SQL query which will turn on TDE but is there any other way?
kat1330
(111 rep)
Mar 31, 2015, 06:51 PM
2
votes
1
answers
1078
views
Prevent Subscription to report from running on a holiday
I have a SQL Server that I am using for building and distributing reports. I have built all the packages for importing data as needed as SSIS packages. These reports only need to be run after the data has been imported. I have built my SSIS packages to check and make sure that the day isn't a holida...
I have a SQL Server that I am using for building and distributing reports. I have built all the packages for importing data as needed as SSIS packages. These reports only need to be run after the data has been imported. I have built my SSIS packages to check and make sure that the day isn't a holiday by comparing the date to a table that contains holidays. This way my data is only imported on business days. The problem is, my report subscriptions are set to run at a specific time Monday - Friday. How can I programmatically run the subscription at the end of my import, so that it only runs on the days that the import runs and not on the holidays?
JamesTheDev
(155 rep)
Dec 4, 2014, 09:15 PM
• Last activity: Dec 4, 2014, 09:24 PM
Showing page 1 of 20 total questions