Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15264

Msg 8624, Level 16, State 1, Procedure broadcast_item_delete, Line 39 Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.

$
0
0

I have a very simple procedure which is crashing with this error. 

we are using sql2008. the FK to table rashim_titles is causing the problem as when I drop the FK it works

the crashing statement:

exec broadcast_item_delete @item=7573605 (it crashes even with no data in the table)

Msg 8624, Level 16, State 1, Procedure broadcast_item_delete, Line 49
Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.

the 2 tables and the procedure:

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[broadcast_items](
[broadcast_item_code] [int] IDENTITY(1,1) NOT NULL,
[channel_code] [tinyint] NOT NULL,
[broadcast_item_type_code] [tinyint] NOT NULL,
[broadcast_item_name] [nvarchar](50) NOT NULL,
[duration] [decimal](6, 2) NOT NULL,
[updated_by] [int] NOT NULL,
[update_time] [smalldatetime] NOT NULL,
[rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
[hafaka_num] [int] NULL,
 CONSTRAINT [PK_broadcast_items] PRIMARY KEY CLUSTERED 
(
[broadcast_item_code] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO



CREATE UNIQUE NONCLUSTERED INDEX [Index_broadcast_items_rg] ON [dbo].[broadcast_items] 
(
[rowguid] ASC
)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, FILLFACTOR = 80) 
GO



CREATE NONCLUSTERED INDEX [IX_broadcast_items] ON [dbo].[broadcast_items] 
(
[channel_code] ASC
)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, FILLFACTOR = 80) 

GO



CREATE NONCLUSTERED INDEX [IX_broadcast_items_1] ON [dbo].[broadcast_items] 
(
[broadcast_item_name] ASC,
[duration] ASC
)
INCLUDE ( [broadcast_item_code],
[channel_code]) 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) 
GO




ALTER TABLE [dbo].[broadcast_items]  WITH NOCHECK ADD  CONSTRAINT [CK_broadcast_items] CHECK NOT FOR REPLICATION ((([duration]*(100)-CONVERT([smallint],[duration],0)*(100))<(60)))
GO

ALTER TABLE [dbo].[broadcast_items] CHECK CONSTRAINT [CK_broadcast_items]
GO

ALTER TABLE [dbo].[broadcast_items] ADD  CONSTRAINT [DF_broadcast_items_update_time]  DEFAULT (getdate()) FOR [update_time]
GO

ALTER TABLE [dbo].[broadcast_items] ADD  CONSTRAINT [DF_broadcast_items_rowguid]  DEFAULT (newsequentialid()) FOR [rowguid]
GO




CREATE TABLE [dbo].[rashim_titles](
[rashim_code] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[schedule_code] [int] NULL,
[broadcast_item_code] [int] NULL,
[edit_worker] [int] NULL,
[broadcast_worker] [int] NULL,
[title] [nvarchar](50) NOT NULL,
[was_connected] [bit] NOT NULL,
[comments] [nvarchar](250) NULL,
[rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
 CONSTRAINT [PK_rashim_titles] PRIMARY KEY CLUSTERED 
(
[rashim_code] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO



CREATE UNIQUE NONCLUSTERED INDEX [Index_rashim_titles_rg] ON [dbo].[rashim_titles] 
(
[rowguid] ASC
)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) 
GO



CREATE UNIQUE NONCLUSTERED INDEX [IX_rashim_titles] ON [dbo].[rashim_titles] 
(
[broadcast_item_code] ASC
)
INCLUDE ( [rashim_code]) 
WHERE ([broadcast_item_code] 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



CREATE NONCLUSTERED INDEX [IX_rashim_titles_1] ON [dbo].[rashim_titles] 
(
[schedule_code] ASC
)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

ALTER TABLE [dbo].[rashim_titles]  WITH CHECK ADD  CONSTRAINT [FK_rashim_titles_broadcast_items] FOREIGN KEY([broadcast_item_code])
REFERENCES [dbo].[broadcast_items] ([broadcast_item_code])
GO

ALTER TABLE [dbo].[rashim_titles] CHECK CONSTRAINT [FK_rashim_titles_broadcast_items]
GO




ALTER TABLE [dbo].[rashim_titles] ADD  CONSTRAINT [DF_rashim_titles_was_connected]  DEFAULT ((0)) FOR [was_connected]
GO

ALTER TABLE [dbo].[rashim_titles] ADD  CONSTRAINT [DF_rashim_titles_rowguid]  DEFAULT (newid()) FOR [rowguid]
GO






SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
create PROCEDURE [dbo].[broadcast_item_delete] 
( @item int ) 
AS
-- writen By David Berlinger 18 Feb 2007
----changed by Maya 07.10.2007

declare @cnt int

-- disallow delete if sheduled
--select @cnt=count(*) from schedules where broadcast_item_code=@item
select @cnt=count(*) from schedules 
where broadcast_item_code=@item or general_broadcast_item_code=@item ----changed by Maya 07.10.2007
if @cnt >0 begin
select result_code='result_code',2
return 2
end
-- disallow delete if previously sheduled
select @cnt=count(*) from schedule_changes where broadcast_item_code=@item 

if @cnt >0 begin
select result_code='result_code',4
return 4
end
-- disallow delete if break sheduled in file
select @cnt=count(*) from schedule_break_details where broadcast_item_code=@item

if @cnt >0 begin
select result_code='result_code',5
return 5
end
-- disallow delete if there is a related promo
select @cnt=count(*) from broadcast_item_promos where related_broadcast_item_code=@item

if @cnt >0 
begin
select result_code='result_code',3
return 3
end
select @cnt=count(*) from rashim_titles 
where broadcast_item_code=@item
and broadcast_item_code is not null

if @cnt >0 
begin
select result_code='result_code',6
return 6
end

delete from broadcast_items  where broadcast_item_code=@item

if @@error >0 begin
select result_code='result_code',0
return 0
end

select result_code='result_code',1
return 1




???


Viewing all articles
Browse latest Browse all 15264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>