I know this command will create a directory:
EXEC master.sys.xp_create_subdir 'C:\testing\'
But how do I check whether 'C:\testing\' exists?
IF EXISTS(...
Right click on the folder in question and select 'Properties', then click on the 'Security' tab. Click 'Edit' and add 'Network Service'. Click 'Apply' and retest. Show activity on this post.
NOT EXISTS is used with a subquery in the WHERE clause to check if the result of the subquery returns TRUE or FALSE. The Boolean value is then used to narrow down the rows from the outer select statement.
CREATE TABLE ResultSet (Directory varchar(200)) INSERT INTO ResultSet EXEC master.dbo.xp_subdirs 'c:\' Select * FROM ResultSet where Directory = 'testing'
Will return a list of sub directories, you can then check the contents of the list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With