Schedule the SSIS package to run on a schedule - sql-server

I am building my first SSIS package which imports a flat file from a folder on File share into a SQL Sever DB table. I have another settings table on the SQL server DB where the Start time is stored, I need to query this table and run my package at that time. If the Settings table has 13:00 as start time, I need to run the SSIS package at 13:00 and check if the file exists in the file share, if the file exists it is imported in to DB else I need to send out an email notification to email alias.
I have built the package that can import the data from the FF to SQL server DB and it is working as expected. But wanted know if the scheduling piece is doable and how we can achieve that. Any suggestion/help is greatly appreciated

You should add the file exists and email steps to the SSIS package that way the one single package can take care of that.
As for the scheduling, you can do that yes.
Create an Agent job that runs say hourly with 2 steps
step 1 can call a stored proc or run your tsql code that does the checks you need, if you exit it with a success code it will then run step 2 which would be your SSIS package.

Related

Automatically Save Query Results to Excel

I have a simple query that I want to run and save the results in excel file on daily basis.
I am trying to create a SSIS(SQL Server Integration Services) package to automate this thing.
My query is
select * from Customers c , Orders o where c.Company = 'Company A'
I was able to create a package and run it using Integration Service, but the issue is that when I make changes in the database and re run the package, instead of overwriting the existing excel, it simply appends the new rows. Is there any way that I can overwrite the existing excel?
The second issue is, I can't see the option to schedule the package under integration services. When I right-click on the package name, I see the following
There is no option to schedule the package.
Is there another way, I can achieve the same purpose? I tried creating a job also -
I choose the target file as an excel file which was already not present in the system -
After the job executes successfully, it creates the excel but I can't open it, it says the file is corrupted.
EDIT : My SSISDB doesn't show any packages. When I created the package, it showed me two options, either store it on sql server or file system, so I chose file system -
Steps how I created the package -
I right clicked the database -> Export Data -> specified the data source-> specified the above query-> saved the ssis on file system .
Initially, my package was not automatically present under the file system.I had to import it manually.
I followed the steps from here -
https://www.mssqltips.com/sqlservertutorial/202/simple-way-to-export-data-from-sql-server/

SQL Job completes successfully but does not execute packages

I have taken a look at several articles including this unanswered question: SQL Server Job runs successfully but doesn't execute packages
I have the exact same problem in SQL Server 2012 using the integration services MSDB catalog. I can execute the SSIS packages manually from that catalog, but the agent job doesn't do anything except state that it completed successfully. I have also executed my SSIS packages from within Visual Studio and they worked just fine. Here's the situation and am wondering if it may be permissions:
SSIS packages look for Excel files matching criteria in a network location.
Once found, the SSIS packages writing the data into the database and archive the file to another folder on that same network location.
Emails are sent upon any failure of import of data into the database or migration into the archive folders.
I have the SQL Agent job running the SSIS packages from a package store (MSDB) using the SQL Server Agent Service Account to run under. Currently we are not doing any sort of project deployment to these servers so I am sticking with package deployment. Here are some steps I've taken:
Run packages manually from Visual Studio 2010 (fully successful).
Run packages manually from SQL Server MSDB catalog (fully successful).
Run job manually from SQL Server Agent using parent package as a step that will execute child packages as an external reference (success but nothing happens).
Run job manually from SQL Server Agent using each package as its own step excluding the parent package (success but nothing happens).
Any ideas? Permissions to the network location or need a proxy? Again, I am running Microsoft SQL Server 2012 Enterprise Edition 64-bit. Many thanks for any help you can provide.
Found the problem. My SSIS package has a foreach loop container and, while the tasks inside the loop container couldn't access the destination, the loop container technically completed successfully. We had to give permissions to the account the steps were running under for the job to correct that. These permissions were put on the network location to allow that account access to read and write to that location. Additionally, my Excel connection was 64-bit so we enabled it to 32-bit runtime and this allowed that portion of the process to complete successfully. I re-enabled any disabled tasks and it looks good to go now. Thanks!
I have also faced this scenario many times but when I checked running the package manually,its completing successfully because I was using for each loop container and sequence container as well.In both cases for each loop and sequence were completing without validating other ones.So I checked precedence constraint and change it,Now it working and all the component ran successfully.
Sometimes we miss to choose appropriate precedence constraint, there are many option like on Success ,failure,completion and then for you can choose values from Constraint ,Expression,Expression AND Constraint and Expression OR Constraint.
Initially i was using Expression OR Constraint for success and now changed it to Expression AND Constraint, its working fine for me.
You also need to do this,it will definitely work please try and let me know.

Issue in concurrently running 2 instances of the same SSIS package in SQL Agent

I created a basic SSIS package in SQL Server 2012 for testing concurrency using SQL Server agent jobs. I want to be able to run copies of the same package as part of different jobs.
Package Design:
There is a variable in the package called ThreadID which represent the thread in which the package is running. This variable is included in the configuration XML file as below:
-
1
There is only one task in the package. It is a simple Exec SQL Task that passes ThreadID to a stored procedure and the stored procedure writes the ThreadID in a SQL Server table.
Result:
Everything works fine when I execute one copy of the package in VS IDE or SQL Server agent job. The issue shows itself when I run two instances of the same package package concurrently in 2 different SQL agent jobs. Each job has a copy of the package file and a configuration XML file. One XML file has ThreadID=1 and another one has ThreadID=2. What I see in the SQL Server table is ThreadID of the job that first started. The table contains all 1 when I start the first job and then the second job. It will be all 2 when I start the second job first.
Any idea why?
Thanks

SSIS Package: Need to update the server name and database name

I have 100 SSIS package all the packages are created in Development environment.
I need to update the server name and database name of all the packages.
It consumes lot of time updating the server name and database name manually.
Is there a way i can update the database and server name in all the packages?
All the packages are stored at same location.
Ideally, you could have a single Master package calling each of your 100 packages which I assume are performing specific tasks. In this Master package, you can pass the Connection Manager details to each 'Child' package during run time itself. The way this is done is by creating variables in each package to hold the server name and database name, and then to update the ConnectionString property in each child package at the start of execution. That way, you only need to generate 1 configuration file for the Master package, and you can configure the database connection parameters as you want. However, this will entail extra development effort as follows:
A new SSIS package to act at Framework level and co-ordinate running the 100 packages
Variables in the new and existing packages to hold server name and database name
A new configuration file in the Master package
The alternative is to just generate configuration files for each of the 100 packages. Then, you will have a separate file for each package, but you will need to make your replacements in each of the configuration files.
You can check out the below links for resources on this:
Configuration Files in SSIS
Variables in SSIS
Have you looked into the "convert to project connection"? If you havent done this yet you are in for a bit of a grind to set it up the first time, but after that you can set your connection for the entire project in 1 place, and configure them in 1 go as well. Just right click on the connection and select the "convert to project connection" for the first connection. Then this project connection becomes visibile for all other components in the project and you can set it up.
Further, if you feel brave and smart you can try to find/replace these settings in the xml code of the packages. This is not easy and not a good idea if you dont know what your doing. If you do know what its all about you can complete this job in 10 minutes flat ;)
Dont say I didnt warn you!
Use update scripts to update internal.object_parameters table
update [SSISDBName].[internal].[object_parameters]
set design_default_value = ‘NewServername’
where design_default_value in (‘OldServerName1′,’OldServerName2’)
update [SSISDBName].[internal].[object_parameters]
set default_value = ‘NewServername’
where default_value in (‘OldServerName1′,’OldServerName2’)
Please find more details on https://moredvikas.wordpress.com/2016/11/17/script-to-update-server-name-in-ssis-package/

sql server 2000 dts package fails when scheduled

I have a SQL Server 2000 dts package which copies data from a DBF file to SQL Table
I have created a System DSN and provided UNC Names for both Connection and Database file itself.
It runs smoothly when ran manually but fails when scheduled as a job?
I googled and found that it has to do with the permissions of SQL Server Agent etc
Can anyone guide me to the right source/post a solution?
"The error says xyz.dbf doesn't exist" in the job history
This is related but separate question
If i am pulling data from one SQL server to another using dts package provided a condition only,For example ,copy the data between the servers if SourceServer table has a value "OK"
i.e if SourceServer.SourceDB.Dbo.CheckStatusTable.Statuscolumn="OK" then copy the value else do not copy
If I have something like above condition how do i embed this into a dts package?
Thanks
Hey - I'll answer the first question in your post regarding the error you are receiving. When you run a DTS package manually, it runs under your context using your permissions. When run as a scheduled job, the package runs under the context of the job agent, in this case SQL Server agent.
It appears that the agent is lacking permissions that you have in attempting to complete the operation. Since the error is mentioning the DBF file, I'd start there. Check any permissions for the file itself or whether the context is being passed properly.

Resources