prod machine: Win2003 Server, Sql Server 2k SP1
dev machine: WinXP Pro, Sql Server 2K SP2
This issue only occurs on the prod machine... during user acceptance testing of course.
WHAT I HAVE DONE
1. I granted the right to run xp_cmdshell with the following (found by Googling "xp_cmdshell permission")
2. I then added the exec xp_cmdshell 'dtsrun...' command to the following trigger (very bottom)
WHAT HAPPENS...
An ASP page executes dbo.sp_UPDATE_GC_ITEM (an SP) which makes an update to dbo.gc_item. Sql server reports that the process is blocking, that the last TSQL command batch was the above mentioned SP, and all activity comes to a halt. I have to manually kill the process or reboot the server.
Removing the exec master.dbo.xp_cmdshell line from the trigger allows the update to happen normally without any blocked processes.
Logging into QUERY ANALYZER as MyUser, I can execute EXEC [master].[dbo].[xp_cmdshell] 'dtsrun /S MyServer /U MyUser /P "MyUser Password" /N kevDTS ' without problems.
Thanks in advance
dev machine: WinXP Pro, Sql Server 2K SP2
This issue only occurs on the prod machine... during user acceptance testing of course.
WHAT I HAVE DONE
1. I granted the right to run xp_cmdshell with the following (found by Googling "xp_cmdshell permission")
Code:
use master
go
xp_sqlagent_proxy_account N'SET'
, N'<mydomain>'
, N'<ntuser>'
, N'<ntuser's password>'
go
-- retrieve the proxy account to check that it's correct.
xp_sqlagent_proxy_account N'GET'
go
-- grant database access in master
sp_grantdbaccess 'LimitedUser'
go
grant exec on xp_cmdshell to LimitedUser
go
Code:
ALTER TRIGGER dbo.tr_gc_item ON dbo.gc_item
FOR INSERT, UPDATE
AS
SET NOCOUNT ON
BEGIN
BEGIN TRANSACTION
DECLARE @active_flag varchar(1)
DECLARE @action_code varchar(1)
SET @action_code = 'C' --Default To Change
IF ( UPDATE([gc_contract_name]) OR
UPDATE([gc_contract_number]) OR
UPDATE([gc_contract_start_date]) OR
UPDATE([gc_contract_end_date]) OR
UPDATE([gc_contract_requote_date]) OR
UPDATE([gc_price_protection_date]) OR
UPDATE([gc_contract_tier]) OR
UPDATE([gc_contract_tier_price]) OR
UPDATE([gc_hipa_required]) OR
UPDATE([gc_date_signed]) OR
UPDATE([gc_exclude]) OR
UPDATE([gc_small_business]) OR
UPDATE([gc_large_business]) OR
UPDATE([gc_woman_owned]) OR
UPDATE([gc_minority_owned]) OR
UPDATE([gc_veteran_owned]) OR
UPDATE([gc_hub_zone])
)
BEGIN
INSERT INTO [ob_transaction_out](
[ob_action], [ob_vendor_number], [ob_account_number], [ob_supplier_part_num], [ob_buyer_part_num], [ob_mfr_num],
[ob_global_catalog_num], [ob_unit_price], [ob_uom], [ob_item_description], [ob_gl_account], [ob_qom], [ob_mfr_name],
[ob_long_description],
[ob_catlevel1], [ob_catlevel2], [ob_catlevel3], [ob_catlevel4],
[ob_smartform_name], [ob_contract], [ob_contract_begin_date], [ob_contract_end_date])
SELECT @action_code, gvi.m_vnd_code, gvi.m_vnd_account, gvi.m_vnd_catnum, i.m_item_no, i.m_mfrcatnum,
i.gc_item_id, CAST(i.m_uopprice as varchar(255)), i.m_uop, i.m_descr1, i.m_glcode, i.m_uopconv, i.m_mfrname,
i.ino_description,
isnull(substring(i.ino_unspsc_code, 1, 2) + substring(i.ino_unspsc_desc, 1, 255), 'NUI'),
isnull(substring(i.ino_unspsc_code, 3, 2) + substring(i.ino_unspsc_desc, 1, 255), 'NUI'),
isnull(substring(i.ino_unspsc_code, 5, 2) + substring(i.ino_unspsc_desc, 1, 255), 'NUI'),
isnull(substring(i.ino_unspsc_code, 7, 2) + substring(i.ino_unspsc_desc, 1, 255), 'NUI'),
NULL, i.gc_contract_number, i.gc_contract_start_date, i.gc_contract_end_date
FROM inserted i LEFT OUTER JOIN gc_vnd_item gvi ON i.gc_item_id = gvi.gc_item_id LEFT OUTER JOIN gc_inv_item gii ON gii.gc_item_id = i.gc_item_id
WHERE gvi.m_vnd_primary_flag = 1
END
IF (@@ERROR <> 0)
BEGIN
ROLLBACK TRANSACTION
RETURN
END
COMMIT TRANSACTION
--run the DTS package
EXEC [master].[dbo].[xp_cmdshell] 'dtsrun /S MyServer /U MyUser /P "MyUser Password" /N kevDTS '
END
SET NOCOUNT OFF
WHAT HAPPENS...
An ASP page executes dbo.sp_UPDATE_GC_ITEM (an SP) which makes an update to dbo.gc_item. Sql server reports that the process is blocking, that the last TSQL command batch was the above mentioned SP, and all activity comes to a halt. I have to manually kill the process or reboot the server.
Removing the exec master.dbo.xp_cmdshell line from the trigger allows the update to happen normally without any blocked processes.
Logging into QUERY ANALYZER as MyUser, I can execute EXEC [master].[dbo].[xp_cmdshell] 'dtsrun /S MyServer /U MyUser /P "MyUser Password" /N kevDTS ' without problems.
Thanks in advance