/*
   سه‌شنبه, 12 آبان 1404 - 20:08:22 ب.ظ
   User: 
   Server: TAHERIAN
   Database: ATNDB
   Application: 
*/

Use ATNDBTest
Go
/*=============================================================================================================*/
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 CRM.WorkDetailTask ADD WorkHeaderContactsRef Bigint Null
GO
ALTER TABLE CRM.WorkDetailTask SET (LOCK_ESCALATION = TABLE)
GO

COMMIT

Create Table CRM.WorkHeaderContacts(
	Serial Bigint Identity(1,1) Not Null,
	WorkHeaderRef Bigint Not Null, 
	ContactRef Bigint Not Null,
	Tag Varchar(50) Null) 
GO

Insert Into 
	CRM.WorkHeaderContacts (WorkHeaderRef, ContactRef)
	Select Serial, ContactRef From CRM.WorkHeader