USE [Resources01_Dat]
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7143 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7143
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7144 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7144
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7145 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7145
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7146 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7146
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7147 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7147
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7148 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7148
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7149 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7149
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7150 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7150
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7151 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7151
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7152 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7152
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7153 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7153
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7154 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7154
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 7155 and tBriefDescription = N'Microsoft Office 2013')
BEGIN
	DELETE FROM [dbo].[tblDts] WHERE [nID]=7155
END
GO

------------------------------------------------------------------------------------------

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 486 and Allocated_to_Device___Computer IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [Allocated_to_Device___Computer]=359 WHERE [nID]=486
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 550 and Total_Assets = 1021 and Total_Available = 34 and Total_Allocated IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [Total_Assets]=12, [Total_Available]=0, [Total_Allocated]=12 WHERE [nID]=550
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1522 and Allocated_to_Device___Computer IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [Allocated_to_Device___Computer]=358 WHERE [nID]=1522
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1523 and Allocated_to_Device___Computer IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [Allocated_to_Device___Computer]=360 WHERE [nID]=1523
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1524 and Allocated_to_Device___Computer IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [Allocated_to_Device___Computer]=357 WHERE [nID]=1524
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1525 and Allocated_to_Device___Computer IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [Allocated_to_Device___Computer]=366 WHERE [nID]=1525
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1787 and nUserID IS NULL and Status = 4 and Asset_Location IS NULL and Allocated_to_Department IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [nUserID]=100, [Status]=1, [Asset_Location]=669, [Allocated_to_Department]=616 WHERE [nID]=1787
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1921 and Allocated_to_Device___Computer IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [Allocated_to_Device___Computer]=30 WHERE [nID]=1921
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1922 and Allocated_to_Device___Computer IS NULL)
BEGIN
	UPDATE [dbo].[tblDts] SET [Allocated_to_Device___Computer]=566 WHERE [nID]=1922
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1954 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1954
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1955 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1955
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1956 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1956
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1957 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1957
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1958 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1958
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1959 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1959
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1960 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1960
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1961 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1961
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1962 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1962
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1963 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1963
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1964 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1964
END
GO

IF EXISTS (SELECT nID FROM [tblDts] WHERE nID = 1965 and nStateID = 2 and Status = 4 and Asset_Sub_status = 2)
BEGIN
	UPDATE [dbo].[tblDts] SET [nStateID]=1, [Status]=1, [Asset_Sub_status]=1 WHERE [nID]=1965
END
GO

------------------------------------------------------------------------------------------

IF NOT EXISTS (SELECT nEmpID FROM [tblEmpRes] WHERE nEmpID = 100 and nResID = 1787 and nRoleID = 0 and nOrigResID = 416)
BEGIN
	INSERT INTO [dbo].[tblEmpRes] ([nEmpID], [nResID], [nRoleID], [nOrigResID]) VALUES (100, 1787, 0, 416)
END
GO
