Solved
SQL stored procedure
Posted on 2014-04-14
Hi,
I am trying to save this Stored Procedure into the Object Tree. When I execute it stops with the following error. What I am doing wrong here?
use rpr_dev
/****** Object: StoredProcedure [dbo].[spITS_DestructionHistory] Script Date: 04/14/2014 14:15:34 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
create procedure dbo.spITS_DestructionHistory
-- ALTER Procedure [dbo].[spITS_DestructionHistory]
-- @AsOfDate datetime, -- Date to start looking for
-- @filterString nvarchar(1000) -- company codes to filter on
-- AS
SET NOCOUNT ON
select
--item.item_code,
--CASE
-- WHEN item.warehouse_id is null THEN item.item_code
-- ELSE item.warehouse_id
--END itemcode,
--ltrim(rtrim( item.item_desc)) as item_desc,
--item.cust_id,
--abs(transactions.qty) as Qty,
item.dest_date,
item.dest_date_end,
item.item_code,
item.id_item
--company.comp_name
from item WITH (NOLOCK)
--left join transactions WITH (NOLOCK) on item.id_item = transactions.id_item and transactions.type = '03'
--left join company WITH (NOLOCK) on company.comp_code = item.comp_code
where destroy = 'Y'
and dest_date is Not Null
and dest_date_end is Not Null
-- and PATINDEX('%;' + ltrim(rtrim(item.comp_code)) + ';%', @filterString) > 0
-- AND item.dest_date > @AsOfDate
order by item.comp_code, item.dest_date, item.item_code