SqlServer中通过XML拆分字符串,需要的朋友可以参考下。
代码如下:
DECLARE @idoc int;
DECLARE @doc xml;
set @doc=cast('
- '+replace(@SelectedProjectArray,',','
- ')+'
' as xml)
EXEC sp_xml_preparedocument @Idoc OUTPUT, @doc
SELECT ProjID FROM OPENXML (@Idoc, '/Root/item',2)
WITH (
[ProjID] varchar(10)
)