USE [censusweb_mdb]
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=44 AND [nFieldID]=68 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (44, NULL, 68, 15, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=44 AND [nFieldID]=69 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (44, NULL, 69, 14, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=766 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 766, 11, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=767 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 767, 12, 2)
GO


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

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=706 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 706, 1, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=765 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 765, 2, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=705 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 705, 3, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=709 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 709, 4, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=707 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 707, 5, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=708 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 708, 6, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=54 AND [nFieldID]=710 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (54, NULL, 710, 7, 2)
GO


IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=64 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 64, 1, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=22 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 22, 1, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=65 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 65, 2, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=4 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 4, 10, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=1 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 1, 11, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=600 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 600, 12, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=353 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 353, 0, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=354 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 354, 0, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=912 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 912, 1, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=919 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 919, 1, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=920 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 920, 1, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=908 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 908, 7, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=921 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 921, 2, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=915 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 915, 2, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=927 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 927, 3, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=916 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 916, 3, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=914 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 914, 4, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=913 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 913, 8, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=918 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 918, 9, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=909 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 909, 10, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=911 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 911, 11, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=926 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 926, 5, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=928 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 928, 6, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=925 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 925, 13, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=923 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 923, 14, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=922 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 922, 12, 2)
GO
IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=924 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) VALUES (87, NULL, 924, 15, 2)
GO


IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=29 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) 
	VALUES (87, NULL, 29, 2, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=17 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) 
	VALUES (87, NULL, 17, 3, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=907 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) 
	VALUES (87, NULL, 907, 4, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=14 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) 
	VALUES (87, NULL, 14, 8, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblView] WHERE [nViewID]=87 AND [nFieldID]=15 )
	INSERT [dbo].[tblView] ([nViewID], [nTabID], [nFieldID], [nFieldIndex], [nStatus]) 
	VALUES (87, NULL, 15, 9, 2)
GO

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


