SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using Different Techniques for SQL Server Automation


Using Different Techniques for SQL Server Automation

Author
Message
Haidong Ji
Haidong Ji
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 60
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/



nlitchfield
nlitchfield
SSC-Enthusiastic
SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)

Group: General Forum Members
Points: 149 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
Antares686
Antares686
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: Moderators
Points: 18712 Visits: 785
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.



philcart
philcart
SSCertifiable
SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)

Group: General Forum Members
Points: 6825 Visits: 1441
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
janiezhao
janiezhao
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 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!





Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search