/*
   Saturday, November 16, 202411:33:04 ب.ظ
   User: 
   Server: TEST2\SQL28
   Database: kamel dan 2015
   Application: 
*/

/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.AccDetailTemp
	DROP CONSTRAINT DF__AccDetail__Updat__4E739D3B
GO
ALTER TABLE dbo.AccDetailTemp
	DROP CONSTRAINT DF__AccDetail__Updat__4F67C174
GO
ALTER TABLE dbo.AccDetailTemp
	DROP CONSTRAINT DF__AccDetail__Activ__505BE5AD
GO
CREATE TABLE dbo.Tmp_AccDetailTemp
	(
	ID bigint NOT NULL,
	Code nvarchar(500) NOT NULL,
	Title nvarchar(1000) NOT NULL,
	Type int NOT NULL,
	CreditType int NOT NULL,
	Description nvarchar(2000) NULL,
	Credit decimal(19, 2) NULL,
	Debit decimal(19, 2) NULL,
	UpdateDate datetime NOT NULL,
	Updater bigint NULL,
	Active bit NULL,
	AttachPath nvarchar(1000) NULL,
	TitleNoSpace nvarchar(1000) NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_AccDetailTemp ADD CONSTRAINT
	DF__AccDetail__Updat__4E739D3B DEFAULT (getdate()) FOR UpdateDate
GO
ALTER TABLE dbo.Tmp_AccDetailTemp ADD CONSTRAINT
	DF__AccDetail__Updat__4F67C174 DEFAULT ((0)) FOR Updater
GO
ALTER TABLE dbo.Tmp_AccDetailTemp ADD CONSTRAINT
	DF__AccDetail__Activ__505BE5AD DEFAULT ((1)) FOR Active
GO
IF EXISTS(SELECT * FROM dbo.AccDetailTemp)
	 EXEC('INSERT INTO dbo.Tmp_AccDetailTemp (ID, Code, Title, Type, CreditType, Description, Credit, Debit, UpdateDate, Updater, Active, AttachPath, TitleNoSpace)
		SELECT ID, Code, Title, Type, CreditType, Description, Credit, Debit, UpdateDate, Updater, Active, AttachPath, TitleNoSpace FROM dbo.AccDetailTemp WITH (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.AccDetailTemp
GO
EXECUTE sp_rename N'dbo.Tmp_AccDetailTemp', N'AccDetailTemp', 'OBJECT' 
GO
create      TRIGGER dbo.AccDetailTemp_Delete ON dbo.AccDetailTemp instead of DELETE 
	AS
		
	return
GO
create      TRIGGER dbo.AccDetailTemp_Update ON dbo.AccDetailTemp instead of UPDATE 
	AS

  	return
GO
COMMIT
