在SQLServer2005中将字符串转换为xml
我有一个字符串,我想把它转换成XML,但它给了我一个错误在SQLServer2005中将字符串转换为xml,xml,sql-server-2005,Xml,Sql Server 2005,我有一个字符串,我想把它转换成XML,但它给了我一个错误 <error>A string literal was expected<error> SET @xmlString = '<OrgStructureRole><SurveyId>13</SurveyId><UserName>xyz13</UserName><UserName>rmn456</UserName><Rule
<error>A string literal was expected<error>
SET @xmlString = '<OrgStructureRole><SurveyId>13</SurveyId><UserName>xyz13</UserName><UserName>rmn456</UserName><Rule OrgTreeID=131705></Rule><Rule OrgTreeID=131721></Rule></OrgStructureRole>'
有什么建议吗?我认为它失败了,因为应该引用
规则
节点上的OrgTreeID
属性
<Rule OrgTreeID="131705"></Rule><Rule OrgTreeID="131721"></Rule>
作为一整行给予
SET @xmlString = '<OrgStructureRole><SurveyId>13</SurveyId><UserName>xyz13</UserName><UserName>rmn456</UserName><Rule OrgTreeID="131705"></Rule><Rule OrgTreeID="131721"></Rule></OrgStructureRole>'
SET@xmlString='13xyz13rmn456'
如果这不起作用,试着做一个直接的任务
DECLARE @xml AS XML
SET @xml = '<OrgStructureRole><SurveyId>13</SurveyId><UserName>xyz13</UserName><UserName>rmn456</UserName><Rule OrgTreeID="131705"></Rule><Rule OrgTreeID="131721"></Rule></OrgStructureRole>'
将@xml声明为xml
SET@xml='13xyz13rmn456'
@ankur很高兴能帮助。。。我能问一下我的回答中哪一部分对你有用吗?是引用还是直接分配?
DECLARE @xml AS XML
SET @xml = '<OrgStructureRole><SurveyId>13</SurveyId><UserName>xyz13</UserName><UserName>rmn456</UserName><Rule OrgTreeID="131705"></Rule><Rule OrgTreeID="131721"></Rule></OrgStructureRole>'