USE [censusweb_mdb]
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=86 AND [nQueryID]=2 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (86, 2, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=86 AND [nQueryID]=2 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (86, 10002, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=86 AND [nQueryID]=2 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (86, 10003, 2)
GO

/*** Check In Out ***/
IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=72 AND [nQueryID]=9 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (72, 9, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=72 AND [nQueryID]=11 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (72, 11, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=72 AND [nQueryID]=19 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (72, 19, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=72 AND [nQueryID]=52 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (72, 52, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=72 AND [nQueryID]=54 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (72, 54, 2)
GO

/*** ASSETS LIBRARY ***/
IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=44 AND [nQueryID]=62 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (44, 62, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=44 AND [nQueryID]=63 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (44, 63, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=44 AND [nQueryID]=64 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (44, 64, 2)
GO

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=44 AND [nQueryID]=65 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (44, 65, 2)
GO

/*** HelpDesk ***/
/*** Add Communication_Received ***/
IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=5 AND [nQueryID]=23 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (5, 23, 2);
GO

/*** USERS MANAGE ***/
IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=18 AND [nQueryID]=39 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (18, 39, 2);

IF NOT EXISTS( SELECT * FROM [dbo].[tblQuery] WHERE [nViewID]=18 AND [nQueryID]=40 )
	INSERT [dbo].[tblQuery] ([nViewID], [nQueryID], [nStatus]) VALUES (18, 40, 2);

GO

/*** SW Asset Types ***/
DELETE FROM [tblQuery] WHERE nViewID=83 AND [nQueryID] IN (42,1,4,5)


