April 23, 2008 at 5:59 am
I need to check whether an existing folder is there or not using sql server.
Here to find i used xp_fileexist to get it. But not using temporary table can i get File is a Directory value.. if possible plz give me..
Thanks
Babu.
KSB
-----------------------------
Thousands of candles can be lit from a single candle, and the life of the candle will not be shortened. Knowledge and happiness never decreases by being shared.” - Buddha
April 25, 2008 at 3:23 am
Hi Babu,
I'm a bit confused as to why you don't want to use a temporary table for this. It's the best option. With xp_fileexist you can assign an output parameter for the File Exists result, but sadly, not for the Is Directory.
-- File exists
DECLARE @fileExist INT
EXEC master.dbo.xp_fileExist 'c:\', @fileExist OUTPUT
SELECT @fileExist
You can, if you really don't want to use a temporary table, use the FileSystemObject to see if a folder exists.
-- Folder exists (FSO)
DECLARE @objFso INT
DECLARE @folderName VARCHAR(200)
DECLARE @folderExists VARCHAR(20)
SELECT @folderName = 'c:\Temp'
EXEC sp_OACreate 'Scripting.FileSystemObject', @objFSO OUT
EXEC sp_OAMethod @objFSO, 'FolderExists', @folderExists OUT, @folderName
SELECT @folderExists -- Equals 'True' when exists
Hope this Helps,
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply