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

  • 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

  • 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

Viewing 2 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply