USE [censusweb_mdb]
GO

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

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

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

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

DELETE FROM dbo.tblFieldAttribute WHERE nViewID=54 AND nFieldID IN(705,706,707,708,709,710,765)
GO

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=600 AND [nAttributeID]=56 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 600, 56, N'no', NULL)
GO

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

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

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

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

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

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

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

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

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

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

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=926 AND [nAttributeID]=95 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 926, 95, N'fld_switch.htmpl', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=927 AND [nAttributeID]=56 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 927, 56, N'never', NULL)
GO

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

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=928 AND [nAttributeID]=95 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 928, 95, N'fld_switch.htmpl', NULL)
GO

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

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=15 AND [nAttributeID]=56 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 15, 56, N'no', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=912 AND [nAttributeID]=91 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 912, 91, N'Frequency in hours to import the users.', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=915 AND [nAttributeID]=91 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 915, 91, N'Get this from Azure. This is the same as the Application ID of the VIZOR app registered in Azure.', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=916 AND [nAttributeID]=91 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 916, 91, N'The key is an authentication key generated in Azure in the VIZOR app > Settings > Keys. It is usually hidden after the app is created, so write it down.', NULL)
GO

IF NOT EXISTS (SELECT * FROM [tblFieldAttribute] WHERE [nViewID]=87 AND [nFieldID]=914 AND [nAttributeID]=91 )
	INSERT [dbo].[tblFieldAttribute] ([nViewID], [nFieldID], [nAttributeID], [tAttributeValue], [nStatus]) 
	VALUES (87, 914, 91, N'This is the ID of the directory in Azure. Also known as Directory ID in  Azure Active Directory > Properties.', NULL)
GO


-- Remove Allocated to Device / Computer (Bulk Allocate) and Allocated to Person (Bulk Allocate) fields (no longer used)
DELETE FROM tblFieldAttribute WHERE nViewID=74 AND nFieldID=1100
DELETE FROM tblFieldAttribute WHERE nViewID=74 AND nFieldID=1101
GO


