Use Users_mdb
GO

IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE  TABLE_NAME = 'tblUser' AND COLUMN_NAME = 'Grade_Level' )
	ALTER TABLE [dbo].[tblUser] ADD [Grade_Level] [nvarchar](50) NULL
GO

IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE  TABLE_NAME = 'tblUser' AND COLUMN_NAME = 'Homeroom_Teacher' )
	ALTER TABLE [dbo].[tblUser] ADD [Homeroom_Teacher] [int] NULL
GO

IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE  TABLE_NAME = 'tblUser' AND COLUMN_NAME = 'Parent_Name' )
	ALTER TABLE [dbo].[tblUser] ADD [Parent_Name] [nvarchar](255) NULL
GO
	
IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE  TABLE_NAME = 'tblUser' AND COLUMN_NAME = 'Parent_Email' )
	ALTER TABLE [dbo].[tblUser] ADD [Parent_Email] [nvarchar](255) NULL
GO
	
	

	
/*** DELETE OLD MACROS ***/
DELETE Users_mdb.dbo.tblUser WHERE nID IN (-31, -32, -33, -34, -35, -36, -37,-40,-41,-42,-43,-44,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56, -57,
	-58, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76)
	
GO

IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-31)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-31,'<Parent Email of:Allocated to Person>','<Parent Email of:Allocated to Person>');

IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-32)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-32,'<Parent Email of:Contact>','<Parent Email of:Contact>');

IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-33)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-33,'<Teacher of:Allocated to Person>','<Teacher of:Allocated to Person>');

IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-34)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-34,'<Teacher of:Contact>','<Teacher of:Contact>');

GO


IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-37)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-37,'<Supervisor of:Allocated to Person>','<Supervisor of:Allocated to Person>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-40)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-40,'<Group Members:Admins>','<Group Members:Admins>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-41)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-41,'<Group Members:Customers>','<Group Members:Customers>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-42)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-42,'<Group Members:Developers>','<Group Members:Developers>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-43)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-43,'<Group Members:Employees>','<Group Members:Employees>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-44)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-44,'<Group Members:HelpDesk-Analysts>','<Group Members:HelpDesk-Analysts>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-45)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-45,'<Group Members:Managers>','<Group Members:Managers>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-46)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-46,'<Group Members:QA>','<Group Members:QA>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-47)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-47,'<Group Members:Users>','<Group Members:Users>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-48)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-48,'<Group Members:Human Resources>','<Group Members:Human Resources>');

GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-49)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-49,'<Group Members:Asset Type Admins>','<Group Members:Asset Type Admins>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-50)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-50,'<Group Members:Role Admins>','<Group Members:Role Admins>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-51)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-51,'<Group Members:IT Managers>','<Group Members:IT Managers>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-52)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-52,'<Group Members:SoftwareManagers>','<Group Members:SoftwareManagers>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-53)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-53,'<Group Members:ReleaseManagers>','<Group Members:ReleaseManagers>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-54)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-54,'<Group Members:IT Asset Managers>','<Group Members:IT Asset Managers>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-55)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-55,'<Group Members:Students>','<Group Members:Students>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-56)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-56,'<Group Members:Teachers>','<Group Members:Teachers>');
GO

IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-57)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-57,'<Supervisor of:Contact>','<Supervisor of:Contact>');

GO
	
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-58)
	INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
	VALUES(-58,'<Supervisor of:Requestor Name>','<Supervisor of:Requestor Name>');

GO

IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-59) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-59,'<Job Title:IT Security>','<Job Title:IT Security>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-60) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-60,'<Job Title:Director of Finance>','<Job Title:Director of Finance>');
GO

IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-61) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-61,'<Job Title:IT Director>','<Job Title:IT Director>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-62) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-62,'<Job Title:IT Manager>','<Job Title:IT Manager>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-63) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-63,'<Job Title:CEO Chief Executive Officer>','<Job Title:CEO Chief Executive Officer>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-64) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-64,'<Job Title:Chief Information Officer (CIO)>','<Job Title:Chief Information Officer (CIO)>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-65) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-65,'<Job Title:Database Administrator>','<Job Title:Database Administrator>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-66) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-66,'<Job Title:Director Human Resources>','<Job Title:Director Human Resources>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-67) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-67,'<Job Title:Project Manager>','<Job Title:Project Manager>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-68) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-68,'<Job Title:QA Analyst>','<Job Title:QA Analyst>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-69) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-69,'<Job Title:Team Leader - Technical Support>','<Job Title:Team Leader - Technical Support>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-70) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-70,'<Job Title:Team Leader, Helpdesk>','<Job Title:Team Leader, Helpdesk>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-71) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-71,'<Job Title:Telecommunications Analyst>','<Job Title:Telecommunications Analyst>');
GO
IF NOT EXISTS(SELECT * FROM [tblUser] WHERE nID=-72) 
      INSERT Users_mdb.dbo.tblUser (nID,tName, tUserName)
      VALUES(-72,'<Job Title:Webmaster>','<Job Title:Webmaster>');
GO


/*** Consolidate Category ***/
UPDATE [tblUser] 
	SET nCategoryID=Category
	WHERE nCategoryID Is NULL AND Category Is NOT NULL;
	
	