Get the number of parts in a SQL Server backup media set

Home / Get the number of parts in a SQL Server backup media set

A typical SQL Server backup uses one “DISK =” statement in the backup SQL, which creates a single-part backup. It’s possible to split backups into multiple parts, ostensibly to spread the data over multiple disks or tapes, or to create multiple smaller files that may be more manageable than a single large one. This is done by using multiple device statements in the backup TSQL like, “… DISK = ‘c:\backups\foo1.bak, DISK = c:\backups\foo2.bak, …”.

This example creates an out-of-band, overwriting backup that is split into nine parts.

This next query gets the number of parts of a given SQL Server backup. If you wish to create a new backup that overwrites the existing one, the number of parts (devices) used to create the latest backup must be the same as the existing backup. This TSQL gets the backup’s label data, which contains the number of parts into which the backup was originally split in the [FamilyCount] field. This query would return 9 for the above backup. If a backup was created with the 64 devices (the maximum), then the [FamilyCount] field will contain 64.