0

This error is quite easy to replicate. So before I send a bug to Ola, I'd like to check if maybe I'm doing it wrong. Version is 2018-06-27 20:44:12

I created 3 databases. DB1, DB2 and DB3. I'd like to backup these 3 databases only in this script independently of what other databases exists. According to Ola's homepage, this is the way I interpret it to be written for the @Databases parameter.

Here is the syntax

EXECUTE [dbo].[DatabaseBackup]
@Databases = DB1, DB2, DB3,
@Directory = N'C:\Temp',
@BackupType = 'FULL',
@Verify = 'N',
--@CleanupTime = 360,
@CheckSum = 'Y',
@LogToTable = 'Y',
@NumberOfFiles = 4

I get error:

Msg 119, Level 15, State 1, Line 2 Must pass parameter number 2 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'.

I've tried

  • @Databases = DB1, @Databases = DB2, @Databases = DB3, but then I get error - Parameter '@Databases' was supplied multiple times.
  • I've tried using ; instead of , but still error.
  • Tried [DB1] etc, also error.
  • Tried N', also error

I'm trying to accomplish line 7 on the picture below from Ola Hallengren enter image description here

Any Ideas?

closed as off-topic by Erik Darling, hot2use, Tom V, Colin 't Hart, Marco Aug 28 '18 at 14:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Erik Darling, hot2use, Tom V, Colin 't Hart, Marco
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Hi. I understand why this post is put on hold. I can't reframe. So if anyone with permission rights can move this topic to a better place then go ahead please. It can also be deleted since it was a really (too?)simple problem, and will probavly not be of assistance for the broader public. – stack_henk Aug 29 '18 at 7:24
4

If you examine the code for DatabaseBackup.sql, you'll see that the definition for the parameter @Databases is @Databases nvarchar(max) = NULL. When passing in literals like DB1, DB2, etc., the entire string needs to be surrounded by single quotes - (just like you used for literals for other parameters).

EXECUTE [dbo].[DatabaseBackup]
@Databases = 'DB1, DB2, DB3',
@Directory = N'C:\Temp',
@BackupType = 'FULL',
@Verify = 'N',
--@CleanupTime = 360,
@CheckSum = 'Y',
@LogToTable = 'Y',
@NumberOfFiles = 4

Not the answer you're looking for? Browse other questions tagged or ask your own question.