December 2, 2004 at 3:21 am
Hello!
Are there any functions in SQL that tells me if a file in a dir exists or not?
What's the synax?
-Lars
Please only reply to this newsgroup. All mails would be bounced back.
December 2, 2004 at 3:38 am
some code that can be used in DTS package to check if a file exists:
Function Main()
Dim objFSO
Dim cFilePath
Dim cFileName
cFilePath = "<file path>"
cFileName = "<file name>"
-- instantiate the Scripting Object
set objFSO = CreateObject("Scripting.FileSystemObject")
With objFSO
If .FileExists(cFilePath & cFileName) Then
-- set on Global Variable that file exists............
End if
End With
Set objFSO = Nothing
Main = DTSTaskExecResult_Success
End Function
There are 10 types of people in this world - those that understand binary and those that don't
December 2, 2004 at 4:08 am
master..xp_fileexist 'c:\test'
December 2, 2004 at 5:00 am
Please avoid multiple postings on the same topic!
It almost impossible to check who has answered what where already.
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=148946
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 2, 2004 at 5:03 am
Sorry for the multipost. I only pressed send once, and it came up two times. Again - Sorry
-Lars
Please only reply to this newsgroup. All mails would be bounced back.
December 2, 2004 at 7:09 am
Try this
/******************************************************************************************************
** Check to see if a file exists
******************************************************************************************************/
DECLARE @chkfile INT
DECLARE @exists BIT
EXEC@chkfile = sp_MSget_file_existence 'C:\boot.ini', @exists = @exists output
IF @exists = 1 -- The file exists
PRINT 'File exists'
ELSE
PRINT 'File does not exist'
December 2, 2004 at 10:21 am
To determine if a file exists, not a job for a Query!
To return, update or remove data -- a more proper use of T-SQL, hmm?
For what purpose do you desire this technique? DTS may use VBScript as shown -- different from a query! DTS may contain a query, but the query itself: concerned it not, with file system contents!
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply