我有一個查詢字串來創建 HTML 行
SELECT (
SELECT 'Court 1' as th, 'Court 2' as th, 'Court 3' as th, 'Court 4' as th
FOR XML raw('tr'), ELEMENTS, TYPE
) AS headertr
輸出是
<tr><th>Court 1</th><th>Court 2</th><th>Court 3</th><th>Court 4</th></tr>
有沒有辦法從 SQL 本身添加onclick 函式和類?
uj5u.com熱心網友回復:
目前尚不清楚您希望屬性去哪里,但您可以執行以下操作
SELECT (
SELECT
'myfunction()' AS [th/@onclick],
'SomeClass' AS [th/@class],
th
from (VALUES
('Court 1'),
('Court 2'),
('Court 3'),
('Court 4')
) v(th)
FOR XML PATH(''), ROOT('tr'), TYPE
) AS headertr
資料庫<>小提琴
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/323260.html
標籤:sql sql-server 查询语句
