-
StackOverflow 文件
-
Microsoft SQL Server 教程
-
Sql Server 中的 Split String 函式
-
T-SQL 表變數和 XML
Declare @userList Table(UserKey VARCHAR(60))
Insert into @userList values ('bill'),('jcom'),('others')
--Declared a table variable and insert 3 records
Declare @text XML
Select @text = (
select UserKey from @userList for XML Path('user'), root('group')
)
--Set the XML value from Table
Select @text
--View the variable value
XML: \<group>\<user>\<UserKey>bill\</UserKey>\</user>\<user>\<UserKey>jcom\</UserKey>\</user>\<user>\<UserKey>others\</UserKey>\</user>\</group>