Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql server 2008 Agent job (TSQL)

Author  Topic 

themar42
Starting Member

8 Posts

Posted - 2012-12-03 : 15:44:52
Trying to create a job that steps include finding a file; copying that file; then moving the file. Upon completion an email is sent stating that the job was successful, the email subject should contain the source filename...I keep getting error: "Incorrect syntax near 'objfso'. [SQLSTATE 42000] (Error 102) "

Here's what I have so far:

Dim folder, files, newsfileSET objfso = createobject("Scripting.FileSystemObject")SET f = objfso.getfolder("\\server31\C$\test")SET fc = f.filesSET newfile =

fso.createtextfile("\file_.txt", true)



FOR each f1 IN fcIF LEFT(f1.name, 16) = "file_" then
objfso.copyfile f1, "\\server31\C$\move"
objfso.movefile f1, "\\server31\C$\move2"
SET files = f.files
FOR each "file_" IN files
newfile.writeline(fileg_.name)
nextSET objmessage = createobject("CDO.Message")
objmessage.FROM = "email@email.com"
objmessage.TO = "email@email.com"
objmessage.subject = ("the file called".newfile)
objmessage.textbody = "Job successful."
objmessage.send

endIF
next
SET objfso = nothingSET objmessage = nothing
   

- Advertisement -