Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
clarkbaker1964
Constraint Violating Yak Guru
428 Posts |
Posted - 2005-04-12 : 01:28:30
|
Trying to workout the proper security setup for a DTS package being executed by SQL login account from stored procCreated a DTS package that does a select * from OrdersIt works with System Admin rights, but I don't want to do this soI granted xp_cmdshell to dts_user Northwind with db_dlladmin and db_datareader I can't see what am I missing please helpexec northwind.dbo.usp_run_sqlSET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_run_sql]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)drop procedure [dbo].[usp_run_sql]GOCREATE procedure dbo.usp_run_sqlasbegin declare @ret int , @str varchar , @sql_str varchar(255), @msg varchar(255) set @str = '1' set @msg = 'DTSRun /S "(local)" /U "dts_user" /P "elton1964" /N "run_sql"' exec @ret=master.dbo.xp_cmdshell @sql_str , NO_OUTPUT if (@ret=0) begin return @ret end else begin raiserror ('Package failed to load data. Please contact the DBA.',16,1) return -1 endendGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GOGRANT EXECUTE ON [dbo].[usp_run_sql] TO [dts_user]GO You can do anything at www.zombo.com |
|
|
clarkbaker1964
Constraint Violating Yak Guru
428 Posts |
Posted - 2005-04-12 : 02:08:39
|
Got it... used SP_OA procsHey Darren, Thank you for the article on calling DTS Packages.http://www.databasejournal.com/features/mssql/article.php/10894_1459181_1declare @hr int, @oPKG intEXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUTIF @hr <> 0BEGIN PRINT '*** Create Package object failed' EXEC sp_displayoaerrorinfo @oPKG, @hr RETURNEND--Loading the Package: -- DTSSQLServerStorageFlags :--- DTSSQLStgFlag_Default = 0--- DTSSQLStgFlag_UseTrustedConnection = 256 EXEC @hr = sp_OAMethod @oPKG, 'LoadFromSQLServer("(Local)", "", "", 256, , , , "run_sql")', NULLIF @hr <> 0BEGIN PRINT '*** Load Package failed' EXEC sp_displayoaerrorinfo @oPKG, @hr RETURNEND --Executing the Package: EXEC @hr = sp_OAMethod @oPKG, 'Execute'IF @hr <> 0BEGIN PRINT '*** Execute failed' EXEC sp_displayoaerrorinfo @oPKG , @hr RETURNEND --Cleaning up: EXEC @hr = sp_OADestroy @oPKGIF @hr <> 0BEGIN PRINT '*** Destroy Package failed' EXEC sp_displayoaerrorinfo @oPKG, @hr RETURNEND You can do anything at www.zombo.com |
 |
|
|
|
|
|
|
|