database backup scheduled task not working

  • junk.mail291276 (9/13/2016)


    I'm attaching a screen shot of the results on this query.

    The instance appears to be ACMCAL-LT160\LOCALDB#F1BD7ACE.

    I put that into the backup command like so:

    sqlcmd -S ACMCAL-LT160\LOCALDB#F1BD7ACE -E -Q "EXEC sp_BackupDatabases @backupLocation='C:\SQLBackups\', @databaseName='RiskAliveDev', @backupType='F'"

    But I get the "Error locating server/instance" error.

    That gives us what the problem is though. You are using LocalDB and that uses different connection strings. That is what the issue is. You don't use the Localdb#xxxx reference. What you use depends on the type of LocalDB. When you created that, do you remember if it's an automatic, named or shared instance?

    Sue

  • That gives us what the problem is though. You are using LocalDB and that uses different connection strings. That is what the issue is. You don't use the Localdb#xxxx reference. What you use depends on the type of LocalDB. When you created that, do you remember if it's an automatic, named or shared instance?

    I have no clue. Is there a way for me to find out?

  • I don't know either - I think there is a way using SqlLocalDB utility but I don't have a version to try.

    See if you can connect to the default instance of LocalDB and guess that it's just using defaults.

    Try executing this from the command line to see if you can connect:

    sqlcmd -S "(localdb)\MSSQLLocalDB"

    If your connected, it will just sit there with a 1> waiting for you to do whatever T-SQL commands or type Exit to get out.

    If that throws some errors in connecting, it could actually be the version of sqlcmd being used. If you have other versions of Express, which I think it looked like you do, you may have to call it from the binn directory of the install for 2014. So you just execute it with the full path to sqlcmd in that ddirectory, along the lines of C:\Whatever\PathTo\2014 version of sqlcmd\sqlcmd.exe -S "(localdb)\MSSQLLocalDB"

    It should just default to Windows Authentication using your account so you don't have to specify the credentials.

    If that all works, then your just about there and over the worst of figuring this out. It looks like your very first error was just that you connected to an Express instance that doesn't have the stored procedure.

    Sue

  • I found three instances of sqlcmd.exe on my machine:

    C:\Program Files (x86)\Microsoft SQL Server\110\Tools\binn\sqlcmd.exe

    C:\Program Files (x86)\Microsoft SQL Server\100\Tools\binn\sqlcmd.exe

    C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\sqlcmd.exe

    Only 110 gave me the 1> prompt that you predicted. The other two gave me the "error locating server/instance" message.

    My new command string I tried is this:

    "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\binn\sqlcmd.exe" -S "(localdb)\MSSQLLocalDB" -E -Q "EXEC master.dbo.sp_BackupDatabases @backupLocation='C:\SQLBackups\', @databaseName='RiskAliveDev', @backupType='F'"

    ... but again I get the "could not find stored procedure..." message.

  • junk.mail291276 (9/14/2016)


    I found three instances of sqlcmd.exe on my machine:

    C:\Program Files (x86)\Microsoft SQL Server\110\Tools\binn\sqlcmd.exe

    C:\Program Files (x86)\Microsoft SQL Server\100\Tools\binn\sqlcmd.exe

    C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\sqlcmd.exe

    Only 110 gave me the 1> prompt that you predicted. The other two gave me the "error locating server/instance" message.

    My new command string I tried is this:

    "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\binn\sqlcmd.exe" -S "(localdb)\MSSQLLocalDB" -E -Q "EXEC master.dbo.sp_BackupDatabases @backupLocation='C:\SQLBackups\', @databaseName='RiskAliveDev', @backupType='F'"

    ... but again I get the "could not find stored procedure..." message.

    Your connecting to the correct instance now so that's good. Normally, you would be the owner of a LocalDB but maybe in your case you are not. Do you know what permissions you have?

    By any chance did you inherit the PC with this already installed or did someone else install it?

    Sue

  • I inherited this computer when I first started working here. I don't think (LocalDb)\MSSQLLocalDB was installed after that point. I'm pretty sure it was there from the beginning.

  • junk.mail291276 (9/14/2016)


    I inherited this computer when I first started working here. I don't think (LocalDb)\MSSQLLocalDB was installed after that point. I'm pretty sure it was there from the beginning.

    That was my guess. You have the script to make it work and at this point it looks like you don't have the correct permissions - you can see it but not execute it, pretty sure we tried that one earlier. My guess is if you execute this, it doesn't return 1. It might not let you run it (which means it's 0) but try anyway though:

    SELECT IS_SRVROLEMEMBER('sysadmin')

    Sue

  • It actually does return 1.

Viewing 8 posts - 16 through 22 (of 22 total)

You must be logged in to reply to this topic. Login to reply