but it says login failed when it executes on express edition
Has nothing to do with the edition.
You use SQL login for authentication; is your SQL Server running in "Mixed Mode" = SQL + Windows auth enabled? Default is Windows auth only.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
I want to schedule auto back up of my SQL database in sql express 2012 edition. For that I used batch file and it works on SQL server 2017 but it says login failed when it executes on express edition. Batch Code is as under:
@Echo off
cls
set SqlServer=LAPTOP-GN1OEU2R
set InstanceName=SQLEXPRESS
set Username=sa
set Password=Olwtswl@123
set Database=StatconNoida
set LocalFolder=D:\SQLBackups
rem ************************************
rem * Don't touch anything below here. *
rem ************************************
echo Getting current date and time...
echo.
for /f %%a in ('sqlcmd -S %SqlServer% -U %Username% -P %Password% -Q "SET NOCOUNT ON select ltrim(convert(date, getdate()))" -h -1') do set CurrentDate=%%a
for /f %%a in ('sqlcmd -S %SqlServer% -U %Username% -P %Password% -Q "SET NOCOUNT ON select right('00' + ltrim(datepart(hour, getdate())), 2)" -h -1') do set CurrentHour=%%a
for /f %%a in ('sqlcmd -S %SqlServer% -U %Username% -P %Password% -Q "SET NOCOUNT ON select right('00' + ltrim(datepart(minute, getdate())), 2)" -h -1') do set CurrentMinute=%%a
for /f %%a in ('sqlcmd -S %SqlServer% -U %Username% -P %Password% -Q "SET NOCOUNT ON select right('00' + ltrim(datepart(second, getdate())), 2)" -h -1') do set CurrentSecond=%%a
echo.
echo Backing up database to %LocalFolder%
echo.
SqlCmd -S %SqlServer% -U %Username% -P %Password% -Q "Backup Database %Database% To Disk='%LocalFolder%\%Database%-%CurrentDate%_%CurrentHour%%CurrentMinute%%CurrentSecond%.bak'"
echo.
echo.
Thanks in advance
but it says login failed when it executes on express edition
Has nothing to do with the edition.
You use SQL login for authentication; is your SQL Server running in "Mixed Mode" = SQL + Windows auth enabled? Default is Windows auth only.
Hi @Rajeev Mishra ,
Please try to use mixed authentication. On SSMS, server properties-> security undere Server authentication, select SQL Server and Windows Authentication mode
you backup of all databases in the local named instance of SQLEXPRESS by using a SQLLogin and its password.
There is a doucment about schedule and automate backups of SQL Server databases in SQL Server Express, you can refer to:
https://learn.microsoft.com/en-us/troubleshoot/sql/admin/schedule-automate-backup-database
-------
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Forget about the script and figure out your login.
Open a command prompt and run:
sqlcmd -S SqlServer -U Username -P Password
Until it works.
Also, please post the exact message you are receiving.