SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS - Assign value to a variable - Need ServerName from DestinationConnectionOLEDB as @Enviro from...


SSIS - Assign value to a variable - Need ServerName from DestinationConnectionOLEDB as @Enviro from email

Author
Message
Barry J. Stratta
Barry J. Stratta
Valued Member
Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)

Group: General Forum Members
Points: 71 Visits: 30
I have an SSIS package that has multiple email task that informs of success or failure of package tasks... I have expressions in the email "subject" that I need to get two more parts in it... 1st is the server name the connection is using; when the dtsx package is executed instead of having three packages for test, training production; the connection is changed at runtime; I want to use my user variable or if there's a system that I can't find but whatever I need the connection "ServerName" to be sent in the email...

"Package>>> " + @[System:TongueackageName] +" was executed at>>> " + (DT_WSTR, 40) @[System::StartTime] + " by user>>> " + @[System::UserName] + " on Machine>>> " + @[System::MachineName] + " Server>>>" + @[User::Enviro]


@[User::Enviro] How to get the value to be the server name from the connection manger?


2nd would be good to know for me to use... if I add another User:TotalRecordsAdded how to set the value from the insert task to the user variable??


Thank you,

Barry
GSquared
GSquared
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23693 Visits: 9730
There may be a better way to get the server name, but the way I do it is run an SQL task and query @@SERVERNAME, then store that into a package-level variable from the result-set.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
John Mitchell-245523
John Mitchell-245523
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14271 Visits: 15974
Barry

How do you configure the server name for the connection string? Do you use a dtsConfig file, or a SQL table, or is it hard coded? Does the server name change during package execution (in other words, does the package loop through several servers)? Gus's way will certainly work, but if there's a way to use an existing variable then I think that would be better than incurring a connection to the database.

For your second question, I'd use the OUTPUT clause in your INSERT statement to populate a table variable, the do a SELECT COUNT(*) FROM that variable - that's assuming you're not writing millions of rows at a time into the table?

John
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search