Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


running package from TSQL


running package from TSQL

Author
Message
S_Kumar_S
S_Kumar_S
SSC-Addicted
SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)

Group: General Forum Members
Points: 414 Visits: 1062
Hi
I have a package which will be placed at a shared location and multiple user will execute it with some parameters. As users are non technical, I'll just provide a TQL script where they will specify parameters and execute it.
Here is the script I have. The problem here is that I can't give xp_cmdshell permission to all users for security reasons. I have tried putting it in job and then giving permission to run job. I also tried putting it in proc and giving EXEC permission. BUt seems none will work unless I give permission on xp_cmdshell. Is there a work around to this?


Declare @cmd varchar(1000)

DECLARE @DBName varchar(50)='MyDB1'--Change DB Name here

DECLARE @TableToBeLoaded_1 varchar(100)='MyTable'--Specify 1st Table
DECLARE @PackagePath varchar(1000)='D:\temp\'

DECLARE @MinWeekID int=0

DECLARE @MaxWeekID int=0

SELECT @Cmd = 'DTexec /FILE "' + @PackagePath + 'Package1.dtsx" /MAXCONCURRENT 1 /REPORTING EW /DECRYPT abcd'
+' /SET \Package.Variables[User:BigGrinatabaseName].Value;"' + CAST(@DBName As varchar(50)) + '"'
+' /SET \Package.Variables[User::MinWeekID].Value;"' + CAST(@MinWeekID As varchar(5)) + '"'
+' /SET \Package.Variables[User::MaxWeekID].Value;"' + CAST(@MaxWeekID As varchar(5)) + '"';

print @cmd

EXEC xp_cmdshell 'DTexec /FILE "D:\temp\Package1.dtsx" /MAXCONCURRENT 1 /REPORTING EW /DECRYPT abcd /SET \Package.Variables[User:BigGrinatabaseName].Value;"ProjectDB3" /SET \Package.Variables[User::MinWeekID].Value;"0" /SET \Package.Variables[User::MaxWeekID].Value;"0"';

-----Table Proc Index Performance TSQL &&%$#@*(#@$%.......------------
Deep Into SQL Jungle
David Webb-CDS
David Webb-CDS
SSC Eights!
SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)

Group: General Forum Members
Points: 922 Visits: 8584
How close to real-time does this have to be? Maybe you can just have the users post a 'request' to a table and have a job that runs frequently looking for 'requests'. What would happen if multiple people tried to run the process at the same time?



And then again, I might be wrong ...
David Webb
S_Kumar_S
S_Kumar_S
SSC-Addicted
SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)

Group: General Forum Members
Points: 414 Visits: 1062
it has to be real time as the package will pull some data for user and put in other tables.
Multiple user is no pbm as we have restricted users to pull same data with validations.
David Webb-CDS (6/17/2013)
How close to real-time does this have to be? Maybe you can just have the users post a 'request' to a table and have a job that runs frequently looking for 'requests'. What would happen if multiple people tried to run the process at the same time?


-----Table Proc Index Performance TSQL &&%$#@*(#@$%.......------------
Deep Into SQL Jungle
David Webb-CDS
David Webb-CDS
SSC Eights!
SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)SSC Eights! (922 reputation)

Group: General Forum Members
Points: 922 Visits: 8584
What about giving them permissions to run sp_start_job?



And then again, I might be wrong ...
David Webb
happycat59
happycat59
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3565 Visits: 3107
Have you tried putting your code in a stored procedure and using the "EXECUTE AS" option in that stored procedure so that it executes as a user who is permitted to run xp_cmdshell ?



S_Kumar_S
S_Kumar_S
SSC-Addicted
SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)SSC-Addicted (414 reputation)

Group: General Forum Members
Points: 414 Visits: 1062
This worked...thanks. Didn't try the job one. But thanks for that as well..
happycat59 (6/17/2013)
Have you tried putting your code in a stored procedure and using the "EXECUTE AS" option in that stored procedure so that it executes as a user who is permitted to run xp_cmdshell ?


-----Table Proc Index Performance TSQL &&%$#@*(#@$%.......------------
Deep Into SQL Jungle
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