dbo.spu_seq

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

Name Data Type Length Description
@nomor_untuk varchar 50
@hasil varchar 50

SQL Script

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE PROCEDURE dbo.spu_seq
 (
 @nomor_untuk as varchar(50), @hasil varchar(50) output
)
AS
BEGIN
 
  DECLARE @nourut bigint
  DECLARE @tahun varchar(8)
  DECLARE @noseq varchar(8)
  set @tahun = (SELECT CONVERT(VARCHAR(8), GETDATE(), 112))
  set @nourut = (select top 1 seq from tbl_seq where number_for=@nomor_untuk)
  set @nourut = @nourut + 1
  update tbl_seq set seq = @nourut where number_for=@nomor_untuk
  set @noseq = (select REPLACE(STR(@nourut, 6, 0), ' ', '0'))
  set @hasil = @tahun + @noseq
END
GO

Depends On

1