Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I know if a folder exists
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00962392
Message ID:
01358024
Vues:
21
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform