hi, I've the following piece of SQL in a SP
SET @SQLStmt = 'SELECT TOP 100
C.CustomerForename + '' '' + C.CustomerSurname As CustomerName,
CASE WHEN C.CustomerStreet = '' THEN
C.CustomerVisitingStreet, C.CustomerVisitingPostcode + '' '' + C.CustomerVisitingTown
C.CustomerStreet, C.CustomerPostcode + '' '' + C.CustomerTown
END As CustomerPostcode,
CASE WHEN Status = 0 THEN ''Open'' ELSE ''Closed'' END As Status,
ISNULL(E.Name,''-'') As Engineer,
CASE WHEN RouteStatus = 0 THEN ''Not Assigned''
WHEN RouteStatus = 1 THEN ''Awaiting Part''
END As RouteStatus
FROM dbo.tbl_Call_Record_Main M
INNER JOIN dbo.tbl_Call_Record_Customers C ON C.AuthNumber = M.AuthNumber
LEFT JOIN dbo.tbl_Engineers E ON M.EngineerID = E.EngineerID
WHERE ' + @SearchTerms + '
ORDER BY M.CallDate DESC '
I've added the section bold and now when I run my program I am getting an incorrect syntax message ( Incorrect syntax near ','.) I just want to check if C.CustomerStreet is blank.
Any help would be appreciated.