Category Archives: SQL Server

Home / SQL Server
48 Posts

SQLServerVersionQueryOutput

Working with a product that uses floats as database keys :^o
This has two solutions to generate float keys.

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.

The database backup is named like “Something_[1-x].bak”, where x is the number of backup file parts.

  • $(DB) is the database name
  • $(CHUNKS) is the number of backup file parts
  • $(PATH) is the path of the first backup file (assumes all of the backup files are in the same directory)

This is a revised version of a solution I lifted from internet postings.

Pilfered and tweaked from internet postings.

s1 is the start of Window 1
e1 is the end of Window 1
s2 is the start of Window 2
e2 is the end of Window 2
s1 < e1
s2 < e2
Window 1 Total Days = (e1 – s1) + 1
>Window 2 Total Days = (e2 – s2) + 1

Example Usage:

TimeWindows

TimeWindowsExampleOutput