"Incorrect syntax near" WHERE "keyword in SQL Server from article
1 answer
You need to specify an alias in the from statement.
So, change this:
FROM [EMERGENCY_CONTACT]
)
For this:
FROM [EMERGENCY_CONTACT]
) AS tbl
Like this:
SELECT [EmpNum], [EmpEmergencyContact], [Relation], [PhType], [Phone]
FROM (
SELECT [EmpNum], [EmpEmergencyContact], [Relation], [PhType], [Phone]
FROM [EMERGENCY_CONTACT]
) AS tbl
It would even be safer to use an alias on columns like this:
SELECT
tbl.[EmpNum],
tbl.[EmpEmergencyContact],
tbl.[Relation],
tbl.[PhType],
tbl.[Phone]
FROM (
SELECT [EmpNum], [EmpEmergencyContact], [Relation], [PhType], [Phone]
FROM [EMERGENCY_CONTACT]
) AS tbl
+12
source to share