Determining Local Server at Runtime

  • Is there a way to determine the local sql server at runtime?  In our enviroment "knowing" which server is running the dts job/package would enable us to dynamically set most other connection/logging variables. 

  • I use:  SELECT @@ServerName

  • But don't you need to already have a connection with the server to then query the serve for the @@servername? 

    Yeah, this didn't work when I switched environments because the connection used to get the @@servername was still set to the dev server. 

  • what method do you use to run the package?  I use global variables to hold the details and set the connection first, if you run the package from dtsrun in a stored procedure you can pass the global settings in. 

  • Actually what I am trying now is to use an Environmental variables (COMPUTERNAME which equates to the @@servername in our environments) to change the Data Source property of my SQL Server connection me in a Dynamic Properties task.  Then I have an ActiveX script that modifies Global Variables according, then another DP Task to make the changes.  It seems to work pretty slick...

Viewing 5 posts - 1 through 4 (of 4 total)

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