Fix Error 1988 “Cannot rebuild clustered index … online because it is disabled” in SQL Server

If you’re getting SQL Server error 1988 that reads something like “Cannot rebuild clustered index ‘PK__Employee__7AD04FF1A39ECAB1’ online because it is disabled.“, it’s probably because you’re trying to rebuild a disabled clustered index online.

We can’t rebuild a disabled clustered index with (ONLINE = ON).

Continue reading

Create a Filtered Index in SQL Server

In SQL Server, a filtered index is a special type of index that only includes a subset of rows from a table or view, based on specified filter criteria.

This criteria would match the criteria of some of the most commonly run queries on the table, thereby helping to improve the performance of those queries.

Below is an example of creating a filtered index in SQL Server.

Continue reading

Fix Error Msg 129 “Fillfactor 0 is not a valid percentage; fillfactor must be between 1 and 100” in SQL Server

If you’re getting SQL Server error Msg 129 that reads “Fillfactor 0 is not a valid percentage; fillfactor must be between 1 and 100“, it appears that you’re trying to set the fillfactor of an index to zero.

While it’s true that zero is the default setting, we can’t actually explicitly set the fillfactor to zero when creating or rebuilding an index.

But all is not lost. Below are two solutions to this problem.

Continue reading

Fix Error 1913 “The operation failed because an index or statistics with name … already exists on table” in SQL Server

If you’re getting SQL Server error 1913 that reads something like “The operation failed because an index or statistics with name ‘IX_Employees_HireDate’ already exists on table ‘Employees’“, it appears that you’re trying to create an index with the same name of one that already exists.

In SQL Server, index names must be unique within a table or view, although they don’t have to be unique within a database. Also, index names must follow the rules of identifiers.

Continue reading

Fix Error “The configuration option ‘fill factor’ does not exist, or it may be an advanced option” in SQL Server

If you’re getting an error that reads “The configuration option ‘fill factor’ does not exist, or it may be an advanced option” in SQL Server, it appears that you’re trying to view or set the default fill factor configuration option.

In SQL Server, fill factor is considered an advanced configuration option. By default, advanced options aren’t available for viewing and changing. However, we can use the following technique to make them available.

Continue reading

Understanding Fillfactor in SQL Server

One of the various options we have when creating or rebuilding indexes in SQL Server is specifying a fillfactor. If we create or rebuild an index without specifying a fillfactor, then the default fillfactor is applied.

In some cases, using the default fillfactor may be fine, even ideal. In other cases it could be less than ideal, even terrible.

Let’s look at what fillfactor is, how it works, and how we can use it to enhance database performance.

Continue reading

5 Ways to Return UNIQUE Constraints in SQL Server

In SQL Server, we can use UNIQUE constraints to ensure that a column (or columns) contain only unique values. When we have a UNIQUE constraint against a column, the system will prevent any duplicate values are entered into that column.

Sometimes we need to return a list of UNIQUE constraints, so that we simply know what we’re working with. Other times we might want to create scripts for all of our UNIQUE constraints so that we can recreate the constraints later.

Regardless of the reason, here are five methods for returning UNIQUE constraints in a SQL Server database.

Continue reading

Possible Reason for Error 1914 “object is not a user table or view” in SQL Server

If you’re getting an error that reads something like “Index cannot be created on object ‘Customers’ because the object is not a user table or view” it could be that you’re trying to create an index, but there’s also a synonym of the same name (but in a different schema). It would appear that SQL Server thinks that you’re trying to create the index on the synonym instead of the table or view of the same name.

Continue reading