My function looks like this:
CREATE FUNCTION fn_FileSys_DirExists(@dirName AS nvarchar(260))
RETURNS bit
AS
BEGIN
DECLARE @dirExists int
DECLARE @fileResults TABLE
(
file_exists int,
file_is_a_directory int,
parent_directory_exists int
)
INSERT @fileResults (file_exists, file_is_a_directory, parent_directory_exists)
EXEC master.dbo.xp_fileexist @dirName
SELECT @dirExists = file_is_a_directory FROM @fileResults
RETURN @dirExists
END
When I try and execute the above SQL, I get the following error:
Invalid use of a side-effecting operator 'INSERT EXEC' within a function.
I thought operations on a table variable in a function weren't considered side effecting operations?