Question

I am trying to find the data change rate for all databases on a server. In the past, I used Paul Randal's script How much of the database has changed since the last full backup which worked great. Except for databases that have a '-' (hyphen) in the name.

I understand that using '-' in a database name is not really a good practice, but an application creates the databases that way.

Also looked into Paul Randal's another script to trend growth of the databases from backups, but that's not something that will work for me.

Was able to calculate the average growth for data files over a period of time, but I am interested in the actual amount/percentage of data that got changed after the last full backup OR in the last one day/week etc..

Any ideas how to modify Paul Randal's stored procedure to work with hyphens in the database name? Or is something like this even possible?

Please suggest if there are any other options available.

Was it helpful?

Solution

Well, you should be able to fix his procedure with a very simple change. Change this line:

SELECT @dbccPageString = 'DBCC PAGE (' + @dbName + ', '

To this:

SELECT @dbccPageString = 'DBCC PAGE (' + QUOTENAME(@dbName) + ', '

But really, fix your database names. This is not the last thing that will break as a result.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top