I've a query that works OK against a MySQL database, but we've had to migrate the database and applications to SQL Server. Now I'm in trouble getting this query to work.
SELECT
complist.CompName,
complist.CompID,
componenttrace.Remark,
complist.McID,
complist.Station,
complist.Slot,
complist.Amount - complist.Used - ISNULL(complist.Correction,0)
FROM
complist, componenttrace
WHERE
complist.McID = 1004
开发者_StackOverflow中文版AND complist.CompID = componenttrace.CompID
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
ORDER BY
complist.CompName, complist.CompID
On the application, the part that goes
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
is added automatically if there's any value on a given field (i.e. 1.1
).
I have a SQL syntax problem, but don't know how to solve it. Can anyone shed some light here?
thanks,
Gustavo
Without error message is very hard to say what is wrong, but my bet is on the implicit join. Try
SELECT
complist.CompName,
complist.CompID,
componenttrace.Remark,
complist.McID,
complist.Station,
complist.Slot,
complist.Amount - complist.Used - ISNULL(complist.Correction,0)
FROM
complist
INNER JOIN componenttrace ON complist.CompID = componenttrace.CompID
WHERE
complist.McID = 1004
AND UPPER(complist.Station + '.' + complist.Slot) LIKE '%1.1%'
ORDER BY
complist.CompName, complist.CompID
精彩评论