日期:2014-05-17 浏览次数:20593 次
DECLARE @XmlDocumentHandle int
declare @XmlDocument nvarchar(4000)
set @XmlDocument='105 108 111 118 101 121 111 117'
set @XmlDocument=REPLACE(@XmlDocument,' ','</item><item>')
set @XmlDocument=N'<Root><item>'+@XmlDocument+'</item></Root>'
select o.value('.','int') 'item'
into #temp
from (select cast(@XmlDocument as xml) 'x') t
cross apply x.nodes('/Root/item') x(o)
declare @s varchar(8000)
set @s=''
select @s=@s+char(item)
from #temp
print @s
/*
iloveyou
*/
--自动拆成单词,就不好弄了.呵呵
DECLARE @str VARCHAR(255), @sql VARCHAR(MAX)
SET @str = '105 108 111 118 101 121 111 117'
SET @sql = 'SELECT CHAR(' + REPLACE(@str,' ',') + CHAR(') + ')'
EXEC(@sql)
/*
iloveyou
*/