June 24, 2012 at 9:57 pm
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SP_Penerimaan_RWJ]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[SP_Penerimaan_RWJ]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE Procedure SP_Penerimaan_RWJ
@Tgl1 as varchar(255),
@Tgl2 as varchar(255),
@KodePay as varchar (30)
AS
select '1' as NO,'Karcis' as Tindakan, count(distinct(dt.no_transaksi)) as jml_pas
, sum((dt.qty) * (dt.harga)) as jumlah
from detail_transaksi dt join detail_bayar db
on dt.kd_kasir = db.kd_kasir and dt.no_transaksi = db.no_transaksi
and dt.urut= db.urut
where dt.kd_kasir ='01'
and dt.tgl_transaksi between @Tgl1 and @Tgl2
and dt.kd_produk = '1'
and kd_pay in (@KodePay)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
June 25, 2012 at 7:28 am
Sounds like @KodePay is a delimited string? Take a look in my signature at the article about splitting strings.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply