sql ORDER BY clause IN FOR XML

最后都变了- 提交于 2021-01-27 21:10:19

问题


(SELECT t.seccolumnname 'td'
FROM   DbName.TableName t
WHERE  t.firstcolumname = 1
ORDER  BY t.seccolumnname)
FOR XML PATH('tr'), ROOT ('table')  

It gives me an error : Incorrect syntax near the keyword 'order'.

Any ideas and suggestions


回答1:


Not sure why you have it in brackets? Try

SELECT t.seccolumnname 'td'
FROM   DbName.TableName t
WHERE  t.firstcolumnname = 1
ORDER  BY t.seccolumnname
FOR XML PATH('tr'), ROOT ('table')  



回答2:


I can say that ORDER BY clause is invalid in derived tables, as you write in the script above.



来源:https://stackoverflow.com/questions/8039085/sql-order-by-clause-in-for-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!