all groups > sql server dts > march 2004 >
You're in the

sql server dts

group:

Global Variables


Re: Global Variables Justin Engelman
3/20/2004 10:15:36 PM
sql server dts: Hi,
1) in your execute sql task have the sql statement be something like exec
myStoredProc ?, ?, ? where each "?" is a global variable you want to pass as
a parameter to the stored procedure myStoredProc. Then click the parameters
button and set each parameter (each of the "?") to the global variables.
(the first "?" in the statement is the first parameter to set, the 2nd "?"
the 2nd parameter, etc.)

2) I believe: When you right click and execute a dts package, the package is
running in the Windows security context that you are logged in as and
locally on the machine you are running Enterprise Manager and right clicking
on. When you run it as a job it is running on the server and with whatever
permissions the sql server agent has on the operating system. So if the sql
server agent doesn't have permissions to read the file system on the server,
the package will fail since you are trying to read the file system. So, be
sure the user that the sql server agent runs under has Windows permissions
to access the file system (I am not positive on how to do this without
spending the time to set it up myself, but hopefully it will point you in
the right direction). Perhaps this is what is causing your problem?

HTH,
Justin


[quoted text, click to view]

Global Variables Jonesgj
3/20/2004 10:17:52 PM
Two almost related items:

1. I have found how to set the values for these dynamically using VBscript,
but how can I use these in a Execute SQL Task. For example (from a previous
post) I want to collect the sizes of particular drives folders and files for
capacity management. I use VBscript FileSystemObject to do this. I can
update the database directly, but what about storing the values in a global
variable and then using a SQL Task, T-SQL to insert the values.
How do you do this?

2. I have encountered a problem with my VBscript (above) in that it works
fine by right clicking and executing the package manually, but I find it
does not always update the database when run in a scheduled job - I don't
know why. First look it seems to insert some of the records not all but what
ever causes the error, causes the job to fail - I am going to investigate,
but has anyone else had this problem before??

Thanks

JonesG

Re: Global Variables Jonesgj
3/21/2004 8:26:49 AM
Thanks Justin

1) I'll give it a go.
2) I have remote access so I thought I was running it in the correct context
(ie I am not using my client Enterprise Manager, but the one actually on the
remote box) However, are you saying there could be a difference between the
permission EM has and the Agent? I'll check this on Monday - thanks

JonesG

[quoted text, click to view]

Re: Global Variables Allan Mitchell
3/21/2004 10:16:21 AM
#1
Assign the values to Global Variables in the Active Script task so

DTSGlobalVariables("MyVar").Value =

Use in the ExecuteSQL task like this

INSERT TABLE(col list) VALUES(?,?,?)

Using the parameters button you can then assign the Global Variables to the
correct ?

#2
Invariably the "Works interactively but fails when scheduled" problem can be
resolved by this article

http://support.microsoft.com/?kbid=269074


--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


[quoted text, click to view]

Re: Global Variables Justin Engelman
3/21/2004 6:01:43 PM
For #2, the link Allan posted explains it better than I can. But, the
permission EM has is based on the login you are using (not sure, perhaps
someone else can answer this - is it the Windows login you are under, or the
SQL Server login set up for the registered server in EM if you are not using
Win authentication to connect?). When run through a job for sql 2k: "The
security context in which the job is run is determined by the owner of the
job. If the job is owned by a login that is not a member of the Sysadmin
server role, then the package is run under the context of the account setup
as the SQL Agent Proxy Account, and has the rights and permissions of that
account."

HTH,
Justin

[quoted text, click to view]

AddThis Social Bookmark Button