So I was looking at the code for the proc created by Ola's script and noticed a number of variable declarations happening early on (like at line 10) but these variable declarations do not have the DECLARE keyword prefacing the variable identifier.
Then, a couple lines lower, a new batch of variables are declared, but this time with the DECLARE keyword.
I was under the impression that you always needed the DECLARE. Is it a scope thing? Like related to the fact the first set of variables are before the stored proc's begin statement?
Is this undocumented shorthand or can anyone point to documentation?
USE [master] GO /****** Object: StoredProcedure [dbo].[DatabaseBackup] Script Date: 7/20/2015 2:23:36 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[DatabaseBackup] @Databases nvarchar(max), @Directory nvarchar(max) = NULL, @BackupType nvarchar(max), @Verify nvarchar(max) = 'N', @CleanupTime int = NULL, @CleanupMode nvarchar(max) = 'AFTER_BACKUP', @Compress nvarchar(max) = NULL, @CopyOnly nvarchar(max) = 'N', @ChangeBackupType nvarchar(max) = 'N', @BackupSoftware nvarchar(max) = NULL, @CheckSum nvarchar(max) = 'N', @BlockSize int = NULL, @BufferCount int = NULL, @MaxTransferSize int = NULL, @NumberOfFiles int = NULL, @CompressionLevel int = NULL, @Description nvarchar(max) = NULL, @Threads int = NULL, @Throttle int = NULL, @Encrypt nvarchar(max) = 'N', @EncryptionAlgorithm nvarchar(max) = NULL, @ServerCertificate nvarchar(max) = NULL, @ServerAsymmetricKey nvarchar(max) = NULL, @EncryptionKey nvarchar(max) = NULL, @ReadWriteFileGroups nvarchar(max) = 'N', @OverrideBackupPreference nvarchar(max) = 'N', @NoRecovery nvarchar(max) = 'N', @URL nvarchar(max) = NULL, @Credential nvarchar(max) = NULL, @MirrorDirectory nvarchar(max) = NULL, @MirrorCleanupTime int = NULL, @MirrorCleanupMode nvarchar(max) = 'AFTER_BACKUP', @LogToTable nvarchar(max) = 'N', @Execute nvarchar(max) = 'Y' AS BEGIN ---------------------------------------------------------------------------------------------------- --// Source: https://ola.hallengren.com //-- ---------------------------------------------------------------------------------------------------- SET NOCOUNT ON DECLARE @StartMessage nvarchar(max) DECLARE @EndMessage nvarchar(max) DECLARE @DatabaseMessage nvarchar(max) DECLARE @ErrorMessage nvarchar(max)