Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I know if a folder exists
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00962392
Message ID:
01358024
Views:
20
Can we use this to create a new directory from SQL Server? What are limitations of this technique?

I'm sorry, I can not test this at this moment.

>Here's another way using WSH
DECLARE @RetVal int, @FSO int, @hr int, @Folder int
>DECLARE @FolderName varchar(256), @NewFolderName varchar(256)
>SET @FolderName = 'H:\tmp\Klm'
>SET @NewFolderName = 'NewName'
>EXEC @hr = sp_OACreate 'Scripting.FileSystemObject', @FSO OUT
>EXEC @hr = sp_OAMethod @FSO, 'FolderExists', @RetVal OUT, @FolderName
>IF @RetVal <> 0 BEGIN
>	EXEC @hr = sp_OAMethod @FSO, 'GetFolder', @Folder OUT, @FolderName
>	IF @hr = 0
>		EXEC @hr = sp_OASetProperty @Folder, 'Name', @NewFolderName
>END
>EXEC @hr = sp_OADestroy @FSO
>
>>
>>I am trying to determine if a folder exist on my server.
>>If the folder exist I would like to rename it.
>>
>>I know I can use the xp_fileexist extended procedure but I do not know how to determined if it is a folder.
>>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform