Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Using Different Techniques for SQL Server Automation Expand / Collapse
Author
Message
Posted Tuesday, July 6, 2004 1:56 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55, Visits: 60
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/


Post #124948
Posted Monday, August 2, 2004 2:52 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, January 4, 2006 3:35 AM
Points: 31, Visits: 1
Small comment.

I really don't like On Error Resume next in any code - I know vbscripts error handling is poor in the extreme, but I'd write any errors to a text file and then (probably separately) mail an administrator the contents of the text file if there were any. That way you get notified if your maintenance is failing.




Niall Litchfield
Senior DBA
http://www.niall.litchfield.dial.pipex.com
Post #129562
Posted Monday, August 2, 2004 6:22 AM
SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: Moderators
Last Login: Wednesday, September 17, 2014 7:25 AM
Points: 8,369, Visits: 740
You would still need On Error Resume Next to accomplish. I prefer to wrap in functions each bit so I have the effectiveness of a GOTO by being able to jump out of points return the error and have error logic (works in VBScript just takes a bit of work covering sometimes). Just make sure you only use it in conditions you specifically want to trap and handle and make sure you GOTO 0 at you earliest convience. You don't want your code getting out of hand because of the RESUME NEXT condition, I have seen that happen so many times.


Post #129592
Posted Tuesday, August 3, 2004 9:29 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 3:10 PM
Points: 2,693, Visits: 1,205
As one who has been bitten by "On Error Resum Next" I now eliminate it wherever it's encountered. The following snippet is much better for VBScript error handling

On Error Resume Next
[perform a statement]
[capture error variables to local variables]
On Error Goto 0

[Check local variable for error]
etc...

Also, you don't need to use VBScript to delete the files, including those in subdirectories. I use a combination of xp_dirtree, xp_getfiledetails and xp_cmdshell to list and delete files.

xp_dirtree [path], [depth], [include files]
xp_getfiledetails [file spec]



Hope this helps
Phill Carter
--------------------
Colt 45 - the original point and click interface

Australian SQL Server User Groups - My profile
Phills Philosophies
Murrumbeena Cricket Club
Post #129988
Posted Tuesday, August 2, 2005 2:01 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, June 1, 2009 8:11 AM
Points: 19, Visits: 22

I was trying to copy backups from one server to another by:

Exec usp_CopyFiles '\\ServerA\FolderName','\\ServerB\FolderName'

I got the following result:

output                                                                                                                                                                                                                                                         
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Invalid drive specification
0 File(s) copied
NULL

Can anybody tell me why?

Thanks in advance!




Post #206627
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse