declare @des_xml nvarchar(max)
set @des_xml ='<?xml verson="1.0" encoding="utf-8"?><province>'
declare @id bigint
declare @provinceid bigint
declare @name nvarchar(50)
declare cur cursor
for select * from T_Provinces
open cur
fetch next from cur into @id,@name
while @@FETCH_STATUS=0
begin
set @des_xml = @des_xml + '<row id="' + cast(@id as nvarchar(10))+ '" provincename="' + @name + '"/>'
fetch next from cur into @id,@name
end
set @des_xml = @des_xml + '</province>'
close cur
deallocate cur
print @des_xml
积累点滴,沉淀知识。