USE [censusweb_mdb]
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=44 AND [nFieldID]=1073 AND [nAttributeID]=5 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (44, 1073, 5, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=44 AND [nFieldID]=1073 AND [nAttributeID]=62 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (44, 1073, 62, N'SpanTwoWidthOne', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=44 AND [nFieldID]=1074 AND [nAttributeID]=5 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (44, 1074, 5, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=44 AND [nFieldID]=1074 AND [nAttributeID]=62 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (44, 1074, 62, N'SpanTwoWidthOne', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=44 AND [nFieldID]=1075 AND [nAttributeID]=5 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (44, 1075, 5, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=44 AND [nFieldID]=1075 AND [nAttributeID]=62 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (44, 1075, 62, N'SpanTwoWidthOne', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=74 AND [nFieldID]=1212 AND [nAttributeID]=14 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (74, 1212, 14, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=74 AND [nFieldID]=1212 AND [nAttributeID]=60 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (74, 1212, 60, N'SpanTwoWidthOne', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=82 AND [nFieldID]=1212 AND [nAttributeID]=14 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (82, 1212, 14, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=82 AND [nFieldID]=1212 AND [nAttributeID]=60 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (82, 1212, 60, N'SpanTwoWidthOne', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=768 AND [nAttributeID]=14 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 768, 14, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=768 AND [nAttributeID]=60 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 768, 60, N'MemoFieldWidth', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=769 AND [nAttributeID]=14 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 769, 14, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=769 AND [nAttributeID]=60 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 769, 60, N'MemoFieldWidth', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=770 AND [nAttributeID]=14 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 770, 14, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=770 AND [nAttributeID]=60 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 770, 60, N'MemoFieldWidth', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=771 AND [nAttributeID]=14 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 771, 14, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=771 AND [nAttributeID]=60 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 771, 60, N'MemoFieldWidth', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=772 AND [nAttributeID]=14 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 772, 11, N'2', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=54 AND [nFieldID]=772 AND [nAttributeID]=63 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (54, 772, 63, N'SpanTwoWidthOne', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=47 AND [nFieldID]=958 AND [nAttributeID]=91 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (47, 958, 91, N'Reserve this line item for the project for which this purchase was required for.', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=47 AND [nFieldID]=959 AND [nAttributeID]=91 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (47, 959, 91, N'Allocate this line item to the license server for which this purchase was required for.', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=48 AND [nFieldID]=958 AND [nAttributeID]=91 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus])
	VALUES (48, 958, 91, N'Reserve this line item for the project for which this purchase was required for.', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=48 AND [nFieldID]=959 AND [nAttributeID]=91 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (48, 959, 91, N'Allocate this line item to the license server for which this purchase was required for.', NULL)
GO

UPDATE tblFieldAttribute SET tAttributeValue='Reserve this line item for the department for which this purchase was required for.' 
WHERE nViewID=47 AND nFieldID=943 AND nAttributeID=91 AND tAttributeValue='Allocate this line item to the department for which this purchase was required for.'
GO

UPDATE tblFieldAttribute SET tAttributeValue='Reserve this line item for the location for which this purchase was required for.' 
WHERE nViewID=47 AND nFieldID=944 AND nAttributeID=91 AND tAttributeValue='Allocate this line item to the location for which this purchase was required for.'
GO

UPDATE tblFieldAttribute SET tAttributeValue='Reserve this line item for the department for which this purchase was required for.' 
WHERE nViewID=48 AND nFieldID=943 AND nAttributeID=91 AND tAttributeValue='Allocate this line item to the department for which this purchase was required for.'
GO

UPDATE tblFieldAttribute SET tAttributeValue='Reserve this line item for the location for which this purchase was required for.' 
WHERE nViewID=48 AND nFieldID=944 AND nAttributeID=91 AND tAttributeValue='Allocate this line item to the location for which this purchase was required for.'
GO

--Remove the Container field from the Allocation view
DELETE FROM tblFieldAttribute WHERE nViewID=74 AND nFieldID=1095
GO

--don't set the Purchase Reference field to be read-only
DELETE FROM tblFieldAttribute WHERE nFieldID=846 AND nAttributeID=82 AND nViewID IN(45, 53)
GO





