Welcome to blogs.conchango.com Sign in | Join | Help

Welcome to blogs.conchango.com

SSIS Junkie

SSIS: Indirect configurations gotcha

UPDATE: It turns out that in actual fact the workaround isn't nearly as severe as logging off. All you have to do is start a new command window. Thinking about it this kinda makes sense - I'm guessing that the command interpreter (cmd.exe) collects (for want of a better word) all the environment variables when it starts up.

Thans to Stu Preston for pointing this out to me!

-Jamie

 

Any developer knows that building solutions in a lab environment is all well and good but its not till you get out into the real world that the foibles and idiosyncrasies of what you're doing really start to scupper your well designed and thoroughly architected solution. Well tonight I faced just such a situation. I'll tell you about it in a bit but first, here's a little demo I'd like you to try. You can do this on Win XP.

1. Bring up a command window

2. Right click on the "My Computer" icon and select "Properties..."
3. Select "Advanced" tab and click "Environment Variables"
4. Create yourself a new system variable called "test". Give it the value "test1"
5. Type "set" in the command window to bring up your list of environment variables.

Can you see your new "test" variable? No, you can't. It aint there!

6. So carry on. Log off your machine and log back on again
7. Bring up a command window and type "set" again. Suddenly "test" has appeared in the list. Weird right? Why do you have to log off to be able to see all your environment variables?

But wait there's more.

8. Go back to "My Computer" Properties-->Advanced-->Environment Variables and change the value of "test".
9. Back to your command window again. What does "set" say now? Its still got the old value in the "test" variable hasn't it?

Don't you think that's weird? I'm using the same commputer aren't I? I'm logged on as the same person? Why is my command interface telling me something different from my GUI?

OK, so what's my point? Why am I telling you this? Well those of you that have used configurations in SSIS will know that you have the option to store the location of a configuration file in an environment variable. This is called an indirect configuration.

I'm using indirect configurations in my current project and the problems highlighted above have been haunting us today. We were running a package in BIDS as normal and it was executing as expected. We could run it without debugging (CTRL-F5) - again, everything was as expected. BUT, try running it using dtexec or dtexecui after changing your environment variable via the GUI and suddenly everything isn't so rosy.

Our environment variable was originally pointing to a legacy confguration file that had some out of date connection strings in it and even referenced some properties that weren't in our package anymore. We couldn't understand why the package executed just fine in BIDS but failed miserably with innexplicable errors when run from the command line. Our errors on the command line talked about things that weren't even in our configuration file - or so we thought. As you've no doubt worked out by now our package was trying to use the legacy configuration file when run using dtexec.

Finding this was horrible - just horrible. It isn't nice seeing something fail and what you're seeing with your own eyes is completely inexplicable - thats what we faced tonight. Happily we found the problem and everything is working OK again but I hope this post serves to stop people suffering the same problems.

I'd love to know why cmd.exe and the GUI can show different results for the same thing. If anyone can answer that please contact me at the usual place!

-Jamie

 

Published 31 October 2005 23:59 by jamie.thomson

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

jason said:

That's good that you found a workaround, I am sure somewhere down the road we would run into this problem -- I think some things are better off un-solved, for instance, why is it that on occasions (seemingly out of the blue) cAsE does matter in the username in IIS secured_containers, even when the docs clearly state that it doesn't -- solve these mysteries and you will find something so horrible that you will never be able to sleep again:)

Cheers,
Jason
November 2, 2005 20:39
 

Jamie Thomson - Life, the universe and SSIS! said:

By now alot of you will be familiar with Configurations right? I am using XML configuration files extensively...
November 14, 2005 12:02
 

Jamie Thomson - Life, the universe and SSIS! said:

By now alot of you will be familiar with Configurations right? I am using XML configuration files extensively...
November 14, 2005 12:03
 

Kirk Haselden said:

Don't know if you ever figured this out, but environment variables are process specific and inherited from the parent process. Changing one in the control panel doesn't change it for any existing processes, only new ones. You don't need to log out, just open a new command window and the environment variable changes will be available. Also, when you change it in one process, it's only available in that process and all processes it launches.
K
December 29, 2005 10:50
 

Jamie Thomson - Life, the universe and SSIS! said:

By now alot of you will be familiar with Configurations right? I am using XML configuration files extensively...
February 8, 2006 20:42
 

SSIS Junkie said:

By now alot of you will be familiar with Configurations right? I am using XML configuration files extensively

January 16, 2007 18:13
 

Ramil said:

Hi,

I believe there is no need to logoff. Just Launch a new cmd window and you'll see the newly added/updated environment variable.

Btw, great blog.

June 26, 2007 11:54
 

posseke said:

Yeah;

All you need to do is launch a new command window and off you go, there is the environment variable you just changed...

July 27, 2007 10:29
 

Ted Pin said:

This is a great tip. I helped me fix the problem where I couldn't find my newly created env var in my SSIS package; just needed to restart VS.

Thanks a lot.

March 14, 2008 18:36
 

Martin said:

This post really helped me!

I was wondering why our mails weren't able to be sent. The error messages were saying that an SMTP host must be set. I was using the exect same configuration file, pointing to it in an environment variable. After a while I found that the variable was pointing to the wrong filename! I quickly changed it and happily ran the package again (as a Job in SQL Server Agent): SAME error! I double, triple and quadroupled checked the filename but it was correct this time. Aaargh

Using the nifty tool FileMon, I realized that it was still trying to read the missing file. Doh! Now what???

Then I read this post and the comment about how changes to environment variables only affects processes started after the change. I restarted SQL Server Agent and it works!

Thanks a million guys!

April 3, 2008 17:10
 

ul.2007 said:

followed the 1st 4 steps, created an environment variable, and in command window, gave set command, it lists newly created environment variable "Test".

July 18, 2008 00:18

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

Powered by Community Server (Personal Edition), by Telligent Systems