Writing a flat file in SSIS succeeds if run from VisualStudio, fails if run from the Integration Services Catalog - visual-studio-2012

I have an SSIS package that does a Bulk Insert, then executes a SQL Task, and then finally writes some database data to a flat file on our network. The package runs fine if I run it from Visual Studio 2012. However, if I deploy the package to the Integration Services Catalog on a 2012 SQL Server and run it from there, the Bulk Insert and SQL Task run fine, but when the package tries to output to the flat file, I get these error messages:
Cannot open the datafile "\\nyfil006\Projects\Accounting\CostRecovery\Cafe de Novo\HospitalityCharges.csv".
HospitalityCharges Flat File failed the pre-execute phase and returned error code 0xC020200E.
I'm able to output the System::UserName to an errorlog, and it's what I think it should be: an account that has full permissions to the folder in the flat file destination (and its parent folders). I've tried creating a blank version of HospitalityCharges.csv, and DelayValidation is set to True for the Data Flow Task that outputs the flat file. My system admin has granted Network Service permissions to the folder as per this link and this link, but that doesn't help. I've also made the connection string an expression as described here. We've also created a mapped drive and used that for the Destination Connection String instead of a UNC path. No joy. Does anyone know why this is happening?
Another note: if I change the flat file destination to point to the C: drive, the package runs fine, whether I run it from Visual Studio or from the Integration Services Catalog.

Related

setup project for visual studio application using advanced installer with local db data is retrieved but not saved in db

I am using advanced installer (simple) to create the setup project of a GUI i am making in visual studio. upon installation, it is possible to read data from the databse i.e the records that are already added can be read but as i try to save data in databse that function is not working and the application stops working. i think that the connection string is right that is why iam able to read data from it but why cant i update data. plz help.
the databse is is service-based local database
This might happen if you have the database stored in the same install location as your application binaries. Usually that is a folder under Program Files.
You're application cannot write under this location when running as a standard user, and it should never write/store data in that location.
If you're not using the Application Data folder to store your database, I suggest you update your app to do so, this should solve your problem.

Continuous Integration of SQL Server in Visual Studio Online

I was just about to do a continuous integration of SQL Server scripts with VSTS. I have two script files in my visual studio 2015 database project.
createStudentTable.sql => simple create table script
Script.PostDeployment1.sql => :r .\createStudentTable.sql (pointing to the above script)
Now after the successful build in visual studio online I suddenly recognized that a .dacpac file is also created - see this screenshot:
Now my database has around 100 tables + view and stored procedures. Now does this .dacpac file contain the entire schema details? If so then it would be an huge overhead in carrying this .dacpac with every build.
Please advise.
Dacpac file only contains the schema model definition of your database and it does not contain any of table data unless you add all of insert statements in the postdeploymentscript.sql
The overhead of dacpac is that it compares the model in dacpac and your target database when the actual deployment happens.
This is a trade-off. If you don't use dacpac then you will end up doing all the database versions and version migrations by yourself manually or using another tool that can make those database change managements with ALTER statements somewhat easier.
BTW the scale of 100 table can be handled well by dacpac.

ssis importing to an other server

There is a SSIS project which takes data from oracle table and export that into xls file.But before exporting there are File System Task and Execute SQL Task which are supposed to delete xls file and after that create it again. The project looks like on images:
it perfectly works on a lochalhost. But the task is to export a file to other server. Excel file path for "Excel connection manager" is
C:\Users\YIskende\Desktop\New folder\report.xlsx
but how to change that in such a way to make it work with an external server
2 solutions (it depends also from SSIS and SQL Server version)
1) Package Deployment Mode: If you use a package configuration (old SSIS and SQL Server versions), you can create a Configuration database on your server where to store paths and variable values (Menu: SSIS -> Package Configurations)
2) Project Deployment Mode: In SQL Server 2014 version you have a Integration Services Catalogs in SQL Management Studio where deploy your project and save your values

How to add extra files to the Drop Location so they're automatically checked into the Drops folder

Edit: Typical - you write out the question, restart VS and everything is working. :-) I'll leave it here for others in case they get this issue.
We use the online TFS from Microsoft and have created a build definition using the DefaultTemplate.12.xaml.
This build is run on the default hosted build agent provided by MS. Once the build completes the output of the build is automatically checked into the Source Control under the $/Project/Drops folder, and we can use get latest to get the output.
What I want to do is copy some of the source files to the drop location - such that they too are checked in as part of the build output. Ultimately this will be custom files created by some other part of the build process - but for now simply getting non standard file will be sufficient.
What I've done is edited the TFS Build Template to add a new Copy Directory Activity that copies files from the SourceDirectory to the BinariesDirectory, right before the template's standard copy files from BinariesDirectory to DropLocation.
The MS activity is simply a Copy Directory for BinariesDirectory to DropLocation
I've also tried to do this using InvokeProcess and CMD.EXE /C XCOPY but the custom files are not checked in, only the standard build output.
NB:
Just to reiterate - the TFS & Build agent is completely in the MS controlled cloud, and we have no access to changing the drop location to a UNC or other path, and the output is automatically checked into the $/Project/Drops folder in Source Control.

How to connect to SQL database from Visual Studio/ open .mdf file

If I copy an .mdf file created by SQL server management studio and put it in the app_data folder I get this error:
"This database file is not compatible with the current instance of SQL Server.
To resolve this issue, you must upgrade the database file by creating a new data connection, or you must modify the existing connection to this database file.
For more information, see http://go.microsoft.com/fwlink/?LinkId=235986"
And if I attempt to Add connection using the visual studio wizard, choosing the Microsoft SQL server database file and select the file I get this error:
"
Unable to open physical file "path" {access is denied) an attempt to attach an auto named for file "path" a database with the same name exists, or specified file cannot be opened, or it is located on UNC share"
And if I attempt to add a connection choosing the "Microsoft SQL server" option in the choose data source window:
"a network related or instance specific error occurred while establishing a connection to SQL server. the server was not found or was not accessible. Verify the the instance name is correct and that the SQL is configured to allow remote connections..."
The only reason I want to connect visual studio to the database is because VS doesn't allow me to import text files. I have imported a text file into a DB from SQL server management studio and I want to connect it to VS. I've turned off UAC in windows 7 and I have file permissions to the mdf file.
Old question, but just to provide an answer for visitors from Google, the problem is not related to file system access (although Administrator accounts should have full privileges to the folder containing the mdf and log files). The solution is that SQL Management Studio needs to be opened using "Run As Administrator". The elevated permissions will allow SQL Server (or SQLExpress) to attach the older mdf file and update it. Once the db is attached, you can access it in Visual Studio by adding a database connection through the Add New Item->Data->ADO.NET Entity Data Model wizard.

Resources