Although you don't mention it in the question, I assume that the reason you're using an SSIS package rather than simply executing the stored proc from a SQL Agent job is that there are other steps in the process. My other assumption is that you schedule the SSIS package using a SQL Agent job.
The first error message implies that you are creating an OLEDB connection to your Access database but that the database could not be found. It's possible that this is a security problem, and that the Windows account under which the SSIS package is running does not have permissions to the file system location where the Access database is stored.
The second error message seems to back this up - when executing the SP, the linked server connection could not be opened.
To confirm this as the issue, you need to try running the SP in SSMS using the same account under which the SQL Agent service runs.
If this is the problem, you will need either to change the permissions of the SQL Agent service account to allow access to the target location, or copy the access db to a location that the account can access (possibly the local disk) before running the package.
EDIT - in response to additional details:
Now that permission and Networked Drive are mentioned, I think this
may be the problem. However, I am still confused as to why I am able
to manually execute the Stored Procedure from within SQL Server with
the Access DB on a Network Drive?
The Acess linked server is configured to use the security credentials of the account executing the query. When you execute the procedure from SQL Server Management Studio, you are doing so in the context of your Windows account, which must have permissions to the network share.
When the same query is executed by the SQL Agent service, it uses the security context of the service account under which the service is running, which does not have access to the share.
Finally, how can I apply this suggestion? Meaning where in SQL Server
do I configure this feature:
change the permissions of the SQL Agent service account to allow access to the target location
You can find out and change the account under which the SQL Agent service is running in the SQL configuration manager (should be found under Start > All Programs > Microsoft SQL Server 2008 > Configuration Tools. Find "SQL Server Agent" in the list of SQL Server Services and see the "Log On As" column). You may need to switch this to a domain account to get access to the share.
i know it's been a while since the question but i found a possible solution.
This link provides an explanation and examples of how to use the connections available in the connection manager enabled for the Script Component in the SSIS https://msdn.microsoft.com/en-us/library/ms136060.aspx
The portion of code that we are interested is this:
IDTSConnectionManager100 connMgr;
HttpClientConnection100 hcc;
IDTSComponentMetaData100 compMetadata = this.ComponentMetaData; //Just for output purposes.
connMgr = this.Connections.MyWebServer;
hcc = (HttpClientConnection100)cm.AcquireConnection(null);
compMetadata.FireInformation(1, "Message: ", "URL: " + hcc.ServerURL + " User: " + hcc.ServerUserName + " Pwd: " + hcc.GetServerPassword(), "", 0, ref fail);
Best Answer
The more SSISic way of doing this would be through Expressions. Despite seeing multiple variables here, don't worry about them. I have found that when people try to do too much with an Expression, diagnosing and debugging bad logic will leave you reaching for the nearest blunt object.
Variables
FlatFileConnection
, string. Value = "C:\ssisdata\so\input\log.txt"ArchiveName
, string. Evaluate As Expression = True.FormatDate
, string. Evaluate As Expression = True.FileExtensionPosition
, int32, Value = 0. Evaluate As Expression = True;The
FileExtensionPosition
is going to determine the last occurrence of.
in a string.The lazy trick I use for finding the last X in a string is to reverse it. It's then the first element in the string and I can pass 1 as the final parameter to FindString.
FileExtensionPosition
This could be overkill but I see this question as helpful to anyone trying to insert a value before the file extension and I further assume, it may not be a 3 character extension.
FormatDate
This uses the package's start time as a reference point for determining year, month and date. You could use
GETDATE
but if your package starts at 11:59 PM and takes a minute to run, knowing that every time you use GetDate() it's re-evaulated... I'd rather not find out what happens. This expression generates a text string representing a date in the format of YYYY-MM-DDI present it with the line breaks in the expression so you can easily see it and future readers, you can modify it.
ArchiveName
Now it's time to put everything together.
The first line of the expression will get everything up to the first
.
in our connection string.The second line is obvious, we concatenate an underscore
The third line adds in our date string
The fourth line grabs the remaining characters from our period to the end of the string.
Biml
Biml, is the business intelligence markup language, which allows me to describe any business intelligence object in terms of some XML. Yes, I'm using XML to define more XML.
By virtue of grabbing the free BIDS Helper you can play along. Install it for your visual studio instance, right click on your solution to add a new biml file, paste the following, right click on the saved biml file and voila, you have a working sample.
Emitted package should have a Variables window like
Debugging your script
If I put message box calls in before and after the assignment of
sFlatFileConnection
, with a starting value of "C:\ssisdata\so\input\log.txt", your code will assign a value of "C:\ssisdata\so\log.txt2014_10_28 My assumption is you want that date string between the log and the .txt.If I'm using .NET, I'm not going to do the junior league string work I do above with Expressions. Instead, I'm going to make use of the .NET libraries as they've done all the heavy lifting for me. Specifically, I'm going to leverage System.IO.Path.
Thus, I change the extension to the current extension which I prepend _YYYY_MM_DD to.