I have almost finished replacing our applications back end with Sql Server but am coming up against an issue. The following Access query is not working with Sql Server.
SELECT table1.*
FROM table1
INNER JOIN (table2
INNER JOIN table3
ON ( table2.custkey = table3.custkey )
AND ( table2.sequence = table3.sequence ))
ON table1.account = table2.account
WHERE (( LEFT(table2.keyid, 1) = 'B' ))
ORDER BY table3.lastname & table3.firstname,
table1.account;
I have tried multiple variations of this statement but have not been able to get it to work. Some help with this statement will help me modify a few others. Any help would be appreciated.
The only thing that sticks out is “
&” which is+in SQL Server. However,&in access also treats NULL values as the empty string, which needs further processing withISNULLin SQL Server:If I were to write the query in SQL Server from scratch, I would probably do the joins serially rather than do the t2-t3 in a bracket before joining back to t1. The test for the first character would also be expressed as LIKE (a personal preference).