Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check if a directory exists using SQL Server? [closed]

Tags:

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(... 
like image 617
JJ. Avatar asked Dec 07 '12 15:12

JJ.


People also ask

How do you check file is exists in folder SQL Server?

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.

How does where not exists work?

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.


1 Answers

 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.

like image 87
Shiraz Bhaiji Avatar answered Oct 01 '22 20:10

Shiraz Bhaiji