我有以下SQL语句
sql = "SELECT DISTINCT " & _
"'<option value=""' + CAST([alpha] AS VARCHAR) + '"">' + " & _
"[alpha] + '</option>' " & _
"FROM scheme.podetm LEFT OUTER JOIN scheme.poheadm ON scheme.podetm.order_no =scheme.poheadm.order_no WHERE scheme.podetm.product= '"& partnumber & "' Order By [alpha]"
我收到错误
用于SQL Server的Microsoft OLE DB提供程序错误&#39; 80040e14&#39;
如果指定了SELECT DISTINCT,则ORDER BY项必须出现在选择列表中。
第374行
答案 0 :(得分:2)
而不是
Order By [alpha]
在此查询的末尾,您必须编写
Order by '<option value=""' + CAST([alpha] AS VARCHAR) + '"">' + [alpha] + '</option>'