Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

How to pass a variable from Execute SQL Task to SSIS Package variable

$
0
0

Hello.  I'm trying to pass a string value from an Execute SQL Task into a package variable.  I'm not using a stored proc.  I'm simply typing SQL into the task. My goal is to dump a list of SQL logins into a file which I then copy to a remote server.  I'm trying to pass the entire path to the remote server into SSIS. Here is the code I'm using...

DECLARE @DestinationPath nvarchar(128)
DECLARE @MirrorServerName  nvarchar(128)
DECLARE @MirrorRole nvarchar(10)
IF EXISTS
 (SELECT TOP 1 mirroring_role FROM sys.database_mirroring WHERE mirroring_role = 1)
  SET @MirrorServerName = (SELECT TOP 1 mirroring_partner_instance FROM sys.database_mirroring WHERE mirroring_role = 1)
SET @DestinationPath = '\\' + @MirrorServerName + '\c$\temp\' + @@SERVERNAME + '_Logins.sql'

As you can see, I'm simply getting the name of a remote SQL server (a mirroring partner server) into a local variable, and using that to construct a UNC path, which I stuff into a second local variable.

I want to pass the value in the variable @DestinationPath to a package variable (@[User::DestinationPath]) so I can use the path in a File System Task.  The File System Task is failing because the way I set it up, %User::DestinationPath] never has a value.

Can you give me any ideas how to make this happen?  Thanks.


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>