I have switched from blogger to word press. here is my blogger site;
Author: Shahzad Khan
How to run SSIS Packages from Web
This is all about running SSIS Web packages;
DTExec /ISSERVER “\SSISDB\fm\fmimports\ALL_STG_Main_Run.dtsx” /SERVER “172.16.20.13” /Envreference 3
Resources
https://stevestedman.com/2016/05/is-enabling-xp_cmdshell-a-security-risk/
this link is helpful
https://www.timmitchell.net/post/2016/11/28/a-better-way-to-execute-ssis-packages-with-t-sql/
How to script out packages
http://tomaslind.net/2015/12/07/ssisdb-catalog-create_execution/
ErrorDescription
Error 0xC0012050 while executing package from project reference package “STG_SETO_MilestonesImport.dtsx”. Package failed validation from the ExecutePackage task. The package cannot run. .
32 bit and 64 bit office side by side
Download this;
https://www.microsoft.com/en-us/download/details.aspx?id=54920
Open command prompt, navigate to exe and run this;
accessdatabaseengine.exe /quiet
This will help you to install 32 bit office driver along 64 bit.
To validate, try running SQL Agent job in 32 bit. If there is no error, your installation of 32 bit is successful. SQL Agent SSIS jobs by default run in 64 bit.
Installing on SQL Server
Install 64-bit version on SQL Server.
Reference
CS2001 Missing AssemblyAttributes.cs when executing SSIS package deployed to the server
If you get this error;
The reson is permissions;
Navigate to c:\windows\temp. On the temp folder, right click properties, security and advanced. Add your proxy account here and give it full permissions;
Resource
enabling / disabling xp_cmdshell
I am not getting into the discussion of pros and cons of xp_cmdshell. This command helps you to run broad level features inside your SQL server. You can run OS level commands, SSIS packages etc.
Here is how you can enable, disable and use.
To check, if xp_cmdshell is enabled and available to use;
SELECT CONVERT(INT, ISNULL(value, value_in_use)) AS config_value
FROM sys.configurations
WHERE name = 'xp_cmdshell';
Turn on xp_cmdshell
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE
Turn off xp_cmdshell
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 0;
RECONFIGURE
Here is a simple use case;
EXEC xp_cmdshell 'dir c:\'
Here is how you can enable it, use it and disable;
DECLARE @originalSetting INTEGER = 0;
SELECT @originalSetting = CONVERT(INT, ISNULL(value, value_in_use))
FROM sys.configurations
WHERE name = 'xp_cmdshell' ;
IF @originalSetting = 0
BEGIN
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
END
EXEC xp_cmdshell 'dir c:\';
IF @originalSetting = 0
BEGIN
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 0;
RECONFIGURE;
END
You can create a stored procedure and use;
CREATE PROCEDURE sp_SuperCmdShell
(
@commandToRun VARCHAR(1000)
)
AS
BEGIN
-- check to see if xp_cmdshell is enabled, if its not
-- then enable it and run the command then set it back
-- to not enabled.
DECLARE @originalSetting INTEGER = 0;
SELECT @originalSetting = CONVERT(INT, ISNULL(value, value_in_use))
FROM sys.configurations
WHERE name = 'xp_cmdshell' ;
IF @originalSetting = 0
BEGIN
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
END
EXEC xp_cmdshell @commandToRun;
IF @originalSetting = 0
BEGIN
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 0;
RECONFIGURE;
END
END
GO
exec #sp_SuperCmdShell 'dir c:\';
This is not a new feature. It came out with early release of SQL server. If you see the usage command, they are OS level command. With the super privileged access any body can run a “format c:\” OS command and leave your database server in unrecoverable state. My suggestion would be to use it with least privileged proxy account.