我的存储过程中有 T-SQL 语句,这给了我错误。但是相同的查询在查询窗口中运行得很好。它给出了错误说
'.' 附近的语法不正确
Set @SQL='Select ''<a href="javascript:editTicketByIDAction('' +
CONVERT(VarChar(Max), Ticket) + '')">'' +
CONVERT(VarChar(Max),t1.Ticket) +
''</a>'' t1.Ticket,VendorTicket[Vendor Ticket], Comments
From VendorTickets t1
WHERE NotifyOn <= GetDate() And NotifyOn Is Not Null AND
NOT EXISTS(SELECT * FROM VendorTickets t2
WHERE t1.Ticket = t2.Ticket AND t1.InitiatedOn < t2.InitiatedOn)'
Exec(@SQL)
没有 T-SQL 它运行良好
SELECT t1.Ticket,t1.VendorTicket,t1.Comments
FROM VendorTickets t1 WHERE
NOT EXISTS(SELECT * FROM VendorTickets t2
WHERE t1.Ticket = t2.Ticket AND t1.InitiatedOn < t2.InitiatedOn)
AND NotifyOn <= GetDate() And NotifyOn Is Not Null