If I understand correctly, you want each row to produce a separate XML document (there is no such thing as an 'XML string'). You need to run each row through the FOR XML. For example, take each row from the table and use the CROSS APPLY
operator to project a single row FOR XML TYPE
. Use a row table value constructor for the join. Eg. using master..spt_values:
select t.*
from master..spt_values s
cross apply (
select s.*
from (values (1) ) as t(c)
for xml path('Boookin'), root('Doc'), type) as t(x)
will return one XML document per row, with a structure like:
<Doc>
<Boookin>
<name>rpc</name>
<number>1</number>
<type>A </type>
<status>0</status>
</Boookin>
</Doc>
Substitute master..spt_values with your table of choice.