Browsed by
Month: August 2017

Trigger AutoNumber di SQL Server

Trigger AutoNumber di SQL Server

Berikut ini trigger buatan saya untuk membuat autonumber, mungkin belum sempurna 100%, tapi paling tidak sudah berjalan dalam 3 tahun terakhir === begin trigger === SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[ti_Quotation] ON [dbo].[Quotation] after insert AS declare @xcounter nvarchar(100), @tahun nvarchar(2), @bulan nvarchar(2), @nomor int; declare @curr_tahun nvarchar(2), @curr_bulan nvarchar(2); declare xcount cursor for select counter,substring(counter,4,2), substring(counter,6,2),CONVERT(INT,substring(counter,8,5)) from AutoGen where table_name = ‘Quotation’; declare curr_monthyear cursor for select replicate(‘0’,2-len(convert(varchar,MONTH(GETDATE()))))+convert(varchar,MONTH(GETDATE())) , substring(convert(varchar,YEAR(getdate())) ,3,2); open xcount; open…

Read More Read More