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:
01358034
Vues:
19
You could use this object as in any other language.
Just keep in mind that OLE Automation is forbidden by default in SQL Server 2005 and 2008.


>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.
>>>
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform