Sqlbackup parameters argument varchar length
alchemistmatt
Posts: 15
What is the maximum allowed length for the parameters argument provided to the sqlbackup extended stored procedure? varchar(4000), varchar(8000), nvarchar(4000), nvarchar(max)?
The reason I ask is that the BACKUP DATABASES syntax could get quite long if using 32 databases (the maximum allowed by sqlbackup) and if the DB names are long. For example, 32 databases with 64 character names gives 2048 characters, and if the parameter type for the stored procedure is nvarchar, then that's a 4096 length string for the database names alone. When constructing the list of databases to send to sqlbackup, I can monitor the length of the string while adding DBs to the list, but I'd like to know what limits I should be checking for. Some example code:
Thanks,
Matt
The reason I ask is that the BACKUP DATABASES syntax could get quite long if using 32 databases (the maximum allowed by sqlbackup) and if the DB names are long. For example, 32 databases with 64 character names gives 2048 characters, and if the parameter type for the stored procedure is nvarchar, then that's a 4096 length string for the database names alone. When constructing the list of databases to send to sqlbackup, I can monitor the length of the string while adding DBs to the list, but I'd like to know what limits I should be checking for. Some example code:
Declare @DBList varchar(3000) Set @DBList = 'Master,Model,MSDB' Declare @command varchar(4000) Set @command = '-SQL "BACKUP DATABASES [' + @DBList + '] TO DISK = ''\\BackupServer\BackupShare\<DATABASE>\<AUTO>'' WITH MAXDATABLOCK=524288, NAME=''<AUTO>'', DESCRIPTION=''<AUTO>'', ERASEFILES=20, COMPRESSION=3, THREADCOUNT=2, VERIFY, LOGTO=''I:\SqlServerBackup\'', MAILTO_ONERROR = ''BackupMonitor@mydomain.com''"' exec master..sqlbackup @command
Thanks,
Matt
Comments
Your suggestion re a 'simulation' mode is noted, as are your comments on database names using 'special' characters. You can use the single database backup syntax to backup such databases in any case e.g.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8