Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Null on Null Input | False |
| Schema Bound | False |
| Assembly |
Parameters
| Name | Data Type | Length | Description |
|---|---|---|---|
| @tgstart | date | 3 | |
| @tgend | date | 3 | |
| @tipebahan | varchar | 50 |
SQL Script
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE FUNCTION dbo.saldoawal
(
@tgstart date, @tgend date, @tipebahan varchar(50)
)
RETURNS @tblsaldoawal TABLE (
part_no varchar(50) primary key,
qty float null )
--idno bigint identity(1,1),
AS
BEGIN
declare @datesaldoawal date
set @datesaldoawal=(select top 1 date_stock from dbo.tbl_stock_awal order by date_stock desc)
set @datesaldoawal=(select top 1 date_stock from dbo.tbl_stock_awal group by date_stock order by date_stock desc)
--select @datesaldoawal
declare @sta int
set @sta=( select
(case when @datesaldoawal < @tgstart then
(select 1)
when @datesaldoawal > @tgend then
(select 2)
else
(select 3)
end) )
insert into @tblsaldoawal (
part_no
,qty
) select
part_no
,sum(isnull(qty,0)) as qty
from tbl_stock_awal where date_stock=@datesaldoawal and typebahan=@tipebahan
group by part_no
return
END
GO
GO
CREATE FUNCTION dbo.saldoawal
(
@tgstart date, @tgend date, @tipebahan varchar(50)
)
RETURNS @tblsaldoawal TABLE (
part_no varchar(50) primary key,
qty float null )
--idno bigint identity(1,1),
AS
BEGIN
declare @datesaldoawal date
set @datesaldoawal=(select top 1 date_stock from dbo.tbl_stock_awal order by date_stock desc)
set @datesaldoawal=(select top 1 date_stock from dbo.tbl_stock_awal group by date_stock order by date_stock desc)
--select @datesaldoawal
declare @sta int
set @sta=( select
(case when @datesaldoawal < @tgstart then
(select 1)
when @datesaldoawal > @tgend then
(select 2)
else
(select 3)
end) )
insert into @tblsaldoawal (
part_no
,qty
) select
part_no
,sum(isnull(qty,0)) as qty
from tbl_stock_awal where date_stock=@datesaldoawal and typebahan=@tipebahan
group by part_no
return
END
GO