I am using a FileTable in SQL Server 2014 and need to run an executable that parses the file name of any inserted/updated/deleted file and then in turn the executable inserts into other tables on the database the information that was parsed from the name. I do not expect the .exe to run long at all but if it runs into issues, I do not want to lock it for an extended period of time.
For instance:
CREATE PROCEDURE filename_parser
@name nvarchar(255)
AS
BEGIN
DECLARE @exe nvarchar(255)
SET @exe = 'c:\test\my.exe "' + @name + '"'
EXEC master..xp_cmdshell @exe
END
GO
If I run the stored procedure from an INSERT
or UPDATE
trigger, for instance:
USE [db_1]
GO
CREATE TRIGGER [dbo].[i_table_a]
ON
[dbo].[table_a]
AFTER
INSERT
AS
DECLARE @file nvarchar(255)
SELECT TOP 1
@file = name
FROM
inserted
EXEC filename_parser @name = @file
will I end up locking table_a
until the executable completes? Sorry, if the answer is obvious. I have not found a straight forward answer. Any help/pointing in the appropriate direction is appreciated.
Related links:
Do stored procedures lock tables/rows?
SQL Server - How to lock a table until a stored procedure finishes