[英]Syntax error in SQL , Incorrect syntax near ''
Anyone help me spotting what is wrong in this?任何人都帮我发现这有什么问题? Thanks in advanced先谢谢了
The Error comes from this section;错误来自本节;
AND ('''+@searchText+''' = '''' OR (ISNULL(CAST(t1.id as varchar(10)),'''') + '' '' +
ISNULL(CAST(FORMAT(t1.reading_date,@dateformat) as varchar(12)),'''')+'' '' +
ISNULL(t2.description,'''') + '' '' +
ISNULL(t3.equipment_no,'''') + '' '' +
ISNULL(t4.description,'''') + '' '' +
ISNULL(CAST(t1.actual_usage as nvarchar(16)),'''') + '' '' +
ISNULL(t5.uom_code,'''') + '' '' +
ISNULL(CAST(t1.actual_cost as nvarchar(16)),'''') + '' '' +
ISNULL(t6.currency_code,'''') + '' '' +
ISNULL(t1.comment,'''') + '' '' +
ISNULL(CAST(FORMAT(t1.actual_date,@dateformat) as varchar(12)),'''')) LIKE ''%'' '''+@searchText+''' ''%'')
The Error:错误:
Msg 102, Level 15, State 1, Line 59
Incorrect syntax near ''.
You can use CONCAT(string1, string2,...., string_n) instead of doing it manually using + operator.您可以使用 CONCAT(string1, string2,...., string_n) 而不是使用 + 运算符手动进行。 Also, use COALESCE to return column value or empty string.此外,使用 COALESCE 返回列值或空字符串。 This will simplify the query.这将简化查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.