IF NOT EXISTS (SELECT * FROM dbo.sysobjects where id = object_id(N'[dbo].[GiftTokenTransactionsXTab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
 
CREATE TABLE [dbo].[GiftTokenTransactionsXTab](
	[FK_OriginalGlobalTransactionNumber] [int] NOT NULL,
	[FK_GiftTokenId] [int] NOT NULL,
 CONSTRAINT [PK_GiftTokenTransactionsXTab] PRIMARY KEY CLUSTERED 
(
	[FK_OriginalGlobalTransactionNumber] ASC,
	[FK_GiftTokenId] ASC
)
)
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name
  FROM SysObjects WITH (NOLOCK)
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID
    AND SysColumns.Name = 'DateStamp'
    WHERE SysObjects.Name = 'GiftToken'
)
  ALTER TABLE GiftToken ADD DateStamp CHAR(8) NULL
GO

INSERT INTO GiftTokenTransactionsXTab (FK_GiftTokenId, FK_OriginalGlobalTransactionNumber)
SELECT Id, FK_OriginalGlobalTransactionNumber
FROM GiftToken WITH (NOLOCK)
GO