If you are trying to back up your SQL Server databases and add a date to them using sqlcmd, try to do this easily.
First create sp sp_BackupDabases, which you can find here: http://support.microsoft.com/kb/2019698
You can call it from sql cmd using the following command:
sqlcmd -U Damieh -P ilovechocolate -S (local) -Q "EXEC sp_BackupDatabases @backupLocation ='C:\MyBackups\', @BackupType='F'"
I'm sure you already know this, but just in case: -U is the user, -P is the password, -S is the server, and -Q is the request. You can either create a backup of all your databases, or some of them, there are options for this. You can find the saved parameters of the process parameters in the same link that I gave you.
The date will be automatically added, and you can play with the sp code, if you want, elsewhere / in format / format. I use this regularly on servers that don't have non-line sqlserver (which means that I can't schedule backups without using .bat and the task scheduler) with great success.
I apologize if this is not the answer you were looking for =). Have a nice day!
source share