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


sqlcmd' is not recognized as an internal or external command


sqlcmd' is not recognized as an internal or external command

Author
Message
gracey
gracey
SSC-Enthusiastic
SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)

Group: General Forum Members
Points: 192 Visits: 258
Hi, Can you help me to solve my problem with my script. got an error "sqlcmd' is not recognized as an internal or external command" and below is the full script.


@title Database Backup
@color 0a

rem User to Pre or Post Batch Backup
@echo.
@echo Please select:
@echo 1. Pre-Batch Backup - DATABASE NAME PB
@echo 2. Post-Batch Backup - DATABASE NAME PB
@echo.
choice /C 12 /M "Backup Type :"
IF %ERRORLEVEL%==1 SET var3=Pre-DATABASE NAME-PB-FullBackup-
IF %ERRORLEVEL%==2 SET var3=Post-DATABASE NAME-PB-FullBackup-


rem Get the Batch Processing Day per backup type
@echo.
@echo Please select:
@echo 1. MWF - (Monday,Wednesday, Friday)
@echo 2. TTH - (Tuesday, Thurdsay)
@echo.
choice /C 12 /M "Backup ProcDay :"
IF %ERRORLEVEL%==1 SET var2=MWF
IF %ERRORLEVEL%==2 SET var2=TTH

rem Display Parameters before proceeding
@echo.
@echo ================================================
@echo Backup Parameters for your confirmation....
@echo ================================================
@echo Backup Type : %var3%
@echo Batch ProcDay: %var2%
@echo.
@echo.
choice /C YN /M "Are the parameters correct?"
IF %ERRORLEVEL%==1 SET proceed=Yes
IF %ERRORLEVEL%==2 SET proceed=No


if %proceed%==No (
@echo.
@echo Backup terminated...
@echo.
pause
exit
)


set bkpfilepath=H:\Backup\Full Backup\%var3%%var2%.bak



@echo ================================================
@echo Backing up DATABASE NAME Database. Please Wait....
@echo ================================================


sqlcmd -S SERVERNAME -U USERNAME -P PASSWORD -Q "BACKUP DATABASE [DATABASE NAME] TO DISK = N'%bkpfilepath%' WITH NOFORMAT, INIT, NAME = N'DATABASE NAME-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"

set /p var5= Database backup completed. Press any key to continue..
Eddie Wuerch
Eddie Wuerch
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2574 Visits: 2260
Looks like just a path issue. Is the account executing the script able to run sqlcmd from the context of the folder that holds the script file? (log on as script user, open cmd prompt, navigate to script folder, exec sqlcmd to see if it runs).

You may need to add the path to sqlcmd (and also ensure the file is installed) to that user's profile, or use the fill path to sqlcmd in your script.
For example, on my laptop, the command would be C:\mssql\DefaultInstance\100\Tools\Binn\sqlcmd.exe <...parameters...>

Eddie Wuerch
MCM: SQL
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