I need a simple sqlcmd script amending to include error handling
- or -
Post a project like this$$
- Posted:
- Proposals: 0
- Remote
- #1535098
- Expired
Description
Experience Level: Intermediate
Estimated project duration: 1 day or less
General information for the business: N/A
Description of requirements/functionality: Amend the script to produce a log file that details errors encountered.
Specific technologies required: SQL
OS requirements: Windows
Extra notes: I have a relatively simple Sqlcmd script that takes and restores a sql snapshot to a database. It occasionally fails, but there is no error handling. I need someone to add some error handling code so it produces a log file with any errors encountered. Its a pretty quick job for someone who has done error handling before.
==========================================
rem detach the databases
rem ==========================================
SQLCMD -E -Q "ALTER DATABASE [OptimaMI_OLAP] SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
rem ==========================================
rem detach the database
rem ==========================================
SQLCMD -E -Q "EXEC master.dbo.sp_detach_db @dbname = N'OptimaMI_OLAP'"
rem ==========================================
rem Dismount flex clones
rem ==========================================
"D:\Program Files\NetApp\SnapDrive\sdcli" snap unmount -d D:\SQLMP\GMSSQL26M -f
"D:\Program Files\NetApp\SnapDrive\sdcli" snap unmount -d D:\SQLMP\GMSSQL26N -f
rem ==========================================
rem Delete snapshots
rem ==========================================
"D:\Program Files\NetApp\SnapDrive\sdcli" snap delete -m GMSSQL26 -d m -s prdsw1sql32optimami.olap
"D:\Program Files\NetApp\SnapDrive\sdcli" snap delete -m GMSSQL26 -d n -s prdsw1sql32optimami.olap
rem ==========================================
rem create snapshots
rem ==========================================
"D:\Program Files\NetApp\SnapDrive\sdcli" snap create -m GMSSQL26 -s prdsw1sql32optimami.olap -D m n -x -u no
rem ==========================================
rem mount flex clones
rem ==========================================
"D:\Program Files\NetApp\SnapDrive\sdcli" snap mount -r GMSSQL26 -k m -s prdsw1sql32optimami.olap -d D:\SQLMP\GMSSQL26M
"D:\Program Files\NetApp\SnapDrive\sdcli" snap mount -r GMSSQL26 -k n -s prdsw1sql32optimami.olap -d D:\SQLMP\GMSSQL26N
rem ==========================================
rem Attach the databases
rem ==========================================
SQLCMD -E -Q "CREATE DATABASE [OptimaMI_OLAP] ON ( FILENAME = N'D:\SQLMP\GMSSQL26M\Data\OptimaMI_PROD.mdf' ),( FILENAME = N'D:\SQLMP\GMSSQL26M\Data\OptimaMI_PROD2.ndf' ),( FILENAME = N'D:\SQLMP\GMSSQL26N\Logs\OptimaMI_PROD_log.ldf' ) FOR ATTACH"
Description of requirements/functionality: Amend the script to produce a log file that details errors encountered.
Specific technologies required: SQL
OS requirements: Windows
Extra notes: I have a relatively simple Sqlcmd script that takes and restores a sql snapshot to a database. It occasionally fails, but there is no error handling. I need someone to add some error handling code so it produces a log file with any errors encountered. Its a pretty quick job for someone who has done error handling before.
==========================================
rem detach the databases
rem ==========================================
SQLCMD -E -Q "ALTER DATABASE [OptimaMI_OLAP] SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
rem ==========================================
rem detach the database
rem ==========================================
SQLCMD -E -Q "EXEC master.dbo.sp_detach_db @dbname = N'OptimaMI_OLAP'"
rem ==========================================
rem Dismount flex clones
rem ==========================================
"D:\Program Files\NetApp\SnapDrive\sdcli" snap unmount -d D:\SQLMP\GMSSQL26M -f
"D:\Program Files\NetApp\SnapDrive\sdcli" snap unmount -d D:\SQLMP\GMSSQL26N -f
rem ==========================================
rem Delete snapshots
rem ==========================================
"D:\Program Files\NetApp\SnapDrive\sdcli" snap delete -m GMSSQL26 -d m -s prdsw1sql32optimami.olap
"D:\Program Files\NetApp\SnapDrive\sdcli" snap delete -m GMSSQL26 -d n -s prdsw1sql32optimami.olap
rem ==========================================
rem create snapshots
rem ==========================================
"D:\Program Files\NetApp\SnapDrive\sdcli" snap create -m GMSSQL26 -s prdsw1sql32optimami.olap -D m n -x -u no
rem ==========================================
rem mount flex clones
rem ==========================================
"D:\Program Files\NetApp\SnapDrive\sdcli" snap mount -r GMSSQL26 -k m -s prdsw1sql32optimami.olap -d D:\SQLMP\GMSSQL26M
"D:\Program Files\NetApp\SnapDrive\sdcli" snap mount -r GMSSQL26 -k n -s prdsw1sql32optimami.olap -d D:\SQLMP\GMSSQL26N
rem ==========================================
rem Attach the databases
rem ==========================================
SQLCMD -E -Q "CREATE DATABASE [OptimaMI_OLAP] ON ( FILENAME = N'D:\SQLMP\GMSSQL26M\Data\OptimaMI_PROD.mdf' ),( FILENAME = N'D:\SQLMP\GMSSQL26M\Data\OptimaMI_PROD2.ndf' ),( FILENAME = N'D:\SQLMP\GMSSQL26N\Logs\OptimaMI_PROD_log.ldf' ) FOR ATTACH"
Mark H.
100% (3)Projects Completed
4
Freelancers worked with
4
Projects awarded
57%
Last project
14 Apr 2017
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
Hi,
When you need it done?
Best Regards,
Bals.
391958
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies