Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SET Quoted Identifier Error When SQL Agent Job Runs vs. In SSMS

$
0
0

I have a job to create indexes on a custom warehouse made by a third party.  Some of these indexes are filtered.  The job ran fine until a couple of nights ago when I started getting, " CREATE INDEX failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. [SQLSTATE 42000] (Error 1934). "  The strange thing to me is that if I copy the script in the job out to SSMS and run it, then I do not get this error.  The scripts all run fine.  Below is the script.  Can anyone help me identify the problem?

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_OCSignal_EventDateKey_EventName]    Script Date: 11/21/2012 13:02:46 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_OCSignal_EventDateKey_EventName')
DROP INDEX [IX_OCSignal_EventDateKey_EventName] ON [dbo].[CustomerActivity] WITH ( ONLINE = OFF )
GO

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_OCSignal_EventDateKey_EventName]    Script Date: 11/21/2012 13:02:46 ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_OCSignal_EventDateKey_EventName')
CREATE NONCLUSTERED INDEX [IX_OCSignal_EventDateKey_EventName] ON [dbo].[CustomerActivity] 
(
	[Customer_Key] ASC,
	[Open_Close_Signal] ASC,
	[Event_Date_Key] ASC,
	[Event_Name] ASC
)
INCLUDE ( [Event_Time_Key],
[Area],
[User_Number],
[User_Name]) 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  = ON) ON [PRIMARY]
GO

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_DispatchStatus_EventDateKey]    Script Date: 11/29/2012 10:17:18 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_DispatchStatus_EventDateKey')
DROP INDEX [IX_DispatchStatus_EventDateKey] ON [dbo].[CustomerActivity] WITH ( ONLINE = OFF )
GO

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_DispatchStatus_EventDateKey]    Script Date: 11/29/2012 10:17:19 ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_DispatchStatus_EventDateKey')
CREATE NONCLUSTERED INDEX [IX_DispatchStatus_EventDateKey] ON [dbo].[CustomerActivity] 
(
	[Customer_Key] ASC,
	[Incident_Dispatch_Status] ASC,
	[Event_Date_Key] ASC
)
INCLUDE ( [Event_Time_Key]) 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  = ON) ON [PRIMARY]
GO



USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_EventCategory_EventDateKey_EventName]    Script Date: 11/20/2012 08:54:29 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_EventCategory_EventDateKey_EventName')
DROP INDEX [IX_EventCategory_EventDateKey_EventName] ON [dbo].[CustomerActivity] WITH ( ONLINE = OFF )
GO

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_EventCategory_EventDateKey_EventName]    Script Date: 11/20/2012 08:54:30 ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_EventCategory_EventDateKey_EventName')
CREATE NONCLUSTERED INDEX [IX_EventCategory_EventDateKey_EventName] ON [dbo].[CustomerActivity] 
(
	[Event_Category] ASC,
	[Customer_Key] ASC,
	[Event_Date_Key] ASC
)
INCLUDE ( [Event_Time_Key],
[Event_Name],
[Area],
[User_Number],
[User_Name]) 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  = ON) ON [PRIMARY]
GO


SET Quoted_Identifier ON

/****** Object:  Index [IX_CodeChangeComments]    Script Date: 01/24/2013 17:43:50 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_CodeChangeComments')
DROP INDEX [IX_CodeChangeComments] ON [dbo].[CustomerActivity] WITH ( ONLINE = OFF )
GO

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_Comments]    Script Date: 01/24/2013 17:43:51 ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_CodeChangeComments')
CREATE NONCLUSTERED INDEX [IX_CodeChangeComments] ON [dbo].[CustomerActivity] 
(
	[Customer_Key] ASC,
	[Event_Date_Key] ASC,
	[Event_Time_Key] ASC
)
INCLUDE ( [Comment]) 
WHERE ([Comment] IS NOT NULL)
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  = ON) ON [PRIMARY]
GO


USE [MYDBNAMEHERE]
GO

/****** Object:  Index [_dta_index_Dates_DateKey_DateText]    Script Date: 02/13/2013 15:26:13 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Dates]') AND name = N'_dta_index_Dates_DateKey_DateText')
DROP INDEX [_dta_index_Dates_DateKey_DateText] ON [dbo].[Dates] WITH ( ONLINE = OFF )
GO

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [_dta_index_Dates_DateKey_DateText]    Script Date: 02/13/2013 15:26:13 ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Dates]') AND name = N'_dta_index_Dates_DateKey_DateText')
CREATE NONCLUSTERED INDEX [_dta_index_Dates_DateKey_DateText] ON [dbo].[Dates] 
(
	[Date_Key] ASC
)
INCLUDE ( [Date_Text]) 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  = ON) ON [PRIMARY]
GO


SET QUOTED_IDENTIFIER ON

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_Event_TypeAlarm_Customer_Key_EventCategory]    Script Date: 03/26/2013 17:13:12 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_Event_TypeAlarm_Customer_Key_EventCategory')
DROP INDEX [IX_Event_TypeAlarm_Customer_Key_EventCategory] ON [dbo].[CustomerActivity] WITH ( ONLINE = OFF )
GO

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [IX_Event_TypeAlarm_Customer_Key_EventCategory]    Script Date: 03/26/2013 17:13:12 ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_Event_TypeAlarm_Customer_Key_EventCategory')
CREATE NONCLUSTERED INDEX [IX_Event_TypeAlarm_Customer_Key_EventCategory] ON [dbo].[CustomerActivity] 
(
	[Event_Type] ASC,
	[Customer_Key] ASC,
	[Event_Category] ASC,
	[Event_Date_Key] ASC,
	[Event_Time_Key] ASC,
	[Event_Name] ASC
)
INCLUDE ( [Area],
[User_Number],
[User_Name],
[Zone],
[Zone_Description]) 
WHERE ([Event_Type]='ALARM')
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  = ON) ON [PRIMARY]
GO

/****** Object:  Index [IX_OriginalEventCode_EventCode_EventDateKey]    Script Date: 05/14/2013 14:06:14 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[CustomerActivity]') AND name = N'IX_OriginalEventCode_EventCode_EventDateKey')
DROP INDEX [IX_OriginalEventCode_EventCode_EventDateKey] ON [dbo].[CustomerActivity] WITH ( ONLINE = OFF )
GO


/****** Object:  Index [IX_OriginalEventCode_EventCode_EventDateKey]    Script Date: 05/14/2013 14:06:14 ******/
CREATE NONCLUSTERED INDEX [IX_OriginalEventCode_EventCode_EventDateKey] ON [dbo].[CustomerActivity] 
(
	[Customer_Key] ASC,
	[Original_Event_Code] ASC,
	[Event_Code] ASC,
	[Event_Date_Key] ASC
)
INCLUDE ( [Event_Time_Key], [User_Number]) 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  = ON) ON [PRIMARY]
GO

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [_dta_index_Customers_6_21575115__K17_K42_K1_K7]    Script Date: 05/17/2013 16:19:25 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Customers]') AND name = N'_dta_index_Customers_6_21575115__K17_K42_K1_K7')
DROP INDEX [_dta_index_Customers_6_21575115__K17_K42_K1_K7] ON [dbo].[Customers] WITH ( ONLINE = OFF )
GO

SET QUOTED_IDENTIFIER ON

USE [MYDBNAMEHERE]
GO

/****** Object:  Index [_dta_index_Customers_6_21575115__K17_K42_K1_K7]    Script Date: 05/17/2013 16:19:26 ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Customers]') AND name = N'_dta_index_Customers_6_21575115__K17_K42_K1_K7')
CREATE NONCLUSTERED INDEX [_dta_index_Customers_6_21575115__K17_K42_K1_K7] ON [dbo].[Customers] 
(
	[Dealer_ID] ASC,
	[Class_Code] ASC,
	[Customer_Key] ASC,
	[Customer_ID] ASC
)
INCLUDE ( [Monitoring_Status]) 
WHERE ([Monitoring_Status]='ACTIVE')
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  = ON) ON [PRIMARY]
GO






Lee Markum


Viewing all articles
Browse latest Browse all 23857

Trending Articles