Nice script. While running this proc during a particular index rebuild, I get the following error:
Msg 536, Level 16, State 5, Procedure dba_WhatSQLIsExecuting, Line 17
Invalid length parameter passed to the SUBSTRING function.
The sql I was running was:
/****** Object: Index [idx_FXT_WHSE] Script Date: 10/28/2008 07:29:21 ******/
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[fact_Forecast]') AND name = N'idx_FXT_WHSE')
DROP INDEX [idx_FXT_WHSE] ON [dbo].[fact_Forecast] WITH ( ONLINE = OFF )
/****** Object: Index [idx_FXT_WHSE] Script Date: 10/28/2008 07:29:39 ******/
CREATE NONCLUSTERED INDEX [idx_FXT_WHSE] ON [dbo].[fact_Forecast]
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF) ON [PRIMARY]
If I comment out the column with the substring, the procedure runs again. Any ideas?