Hi Guys,
I have a bit of SQL which stores information into temp tables however I’m sure there is a better way of do this. Any help or suggestions would be grateful.
SELECT *
INTO #EMAIL
FROM KeyCareClean
WHERE NOT EXISTS
(select *
from STUDENT
where Upper(KeyCareClean.EmailAddress) = UPPER(STUDENT.EMAIL_ADDRESS_FULL))
SELECT *
INTO #MOBILE
FROM #EMAIL
WHERE NOT EXISTS
(select *
from STUDENT
where UPPER(#EMAIL.FirstName) = UPPER(STUDENT.NAME_FORENAME)
AND UPPER(#EMAIL.LastName) = UPPER(STUDENT.NAME_SURNAME)
AND #EMAIL.MobileNo = STUDENT.DAYTIME_TEL)
DROP TABLE #EMAIL
SELECT *
INTO #DOB
FROM #MOBILE
WHERE NOT EXISTS
(select *
from STUDENT
where UPPER(#MOBILE.FirstName) = UPPER(STUDENT.NAME_FORENAME)
AND UPPER(#MOBILE.LastName) = UPPER(STUDENT.NAME_SURNAME)
AND #MOBILE.DOB = CONVERT(VARCHAR(10), STUDENT.DATE_OF_BIRTH, 101))
DROP TABLE #MOBILE
SELECT * FROM #DOB
I have a bit of SQL which stores information into temp tables however I’m sure there is a better way of do this. Any help or suggestions would be grateful.
SELECT *
INTO #EMAIL
FROM KeyCareClean
WHERE NOT EXISTS
(select *
from STUDENT
where Upper(KeyCareClean.EmailAddress) = UPPER(STUDENT.EMAIL_ADDRESS_FULL))
SELECT *
INTO #MOBILE
FROM #EMAIL
WHERE NOT EXISTS
(select *
from STUDENT
where UPPER(#EMAIL.FirstName) = UPPER(STUDENT.NAME_FORENAME)
AND UPPER(#EMAIL.LastName) = UPPER(STUDENT.NAME_SURNAME)
AND #EMAIL.MobileNo = STUDENT.DAYTIME_TEL)
DROP TABLE #EMAIL
SELECT *
INTO #DOB
FROM #MOBILE
WHERE NOT EXISTS
(select *
from STUDENT
where UPPER(#MOBILE.FirstName) = UPPER(STUDENT.NAME_FORENAME)
AND UPPER(#MOBILE.LastName) = UPPER(STUDENT.NAME_SURNAME)
AND #MOBILE.DOB = CONVERT(VARCHAR(10), STUDENT.DATE_OF_BIRTH, 101))
DROP TABLE #MOBILE
SELECT * FROM #DOB