Sql-server – SQL Server 2008 Maintenance Plan Failure

index-tuningsql-server-2008

Instead of using my old school index rebuild script I had decided to use 2008's built-in Maintenance Plan to do a simple Rebuild Index task.

The details are:

  • Connection = Local server connection
  • Databases = Specific databases (just one)
  • Object = Tables and Views
  • Free space options = I have tried both default amount and change percentage to 70%
  • Advanced options = Keep index online while reindexing is the only one checked. This is the primary reason I wanted to use this was to see if we could keep an index online while still doing the rebuild.

When I run the T-SQL from this manually everything works ok, but I assume it is not keeping the index online. Whenever I run the job though I get this very strange error that has not led me anywhere:

Executing the query "ALTER INDEX [Agreement_PK] ON [dbo].[Agreement]
RE…" failed with the following error: "String or binary data would
be truncated. The statement has been terminated.". Possible failure
reasons: Problems with the query, "ResultSet" property not set
correctly, parameters not set correctly, or connection not established
correctly.

USE [<dbase>]
GO
ALTER INDEX [Agreement_PK] ON [dbo].[Agreement] REBUILD PARTITION = ALL WITH ( FILLFACTOR = 30, PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, ONLINE = ON, SORT_IN_TEMPDB = OFF ) 
GO
USE [<dbase>] 
GO
ALTER INDEX [IX_Agreement_1] ON [dbo].[Agreement] REBUILD PARTITION = ALL WITH ( FILLFACTOR = 30, PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, ONLINE = ON, SORT_IN_TEMPDB = OFF ) 
GO

The T-SQL is very generic and gives no indication as to what isn't set correctly or why such a simple local connection would be a problem. EDIT: Here is that code from my comment.

It is set to use Windows NT Integrated security, but I am not sure why that would be a problem again on a local system connection.

Best Answer

You have "SET ANSI_WARNINGS OFF" when running the code as T_SQL

When running the job this setting must be different.