--create an xml variable, and then read an xml document into it.
declare @x xml
declare @y as varchar(1000)
select @y ='<Receivable documentNumber="PYMNT12" documentDate="12/13/2007">'
select @y = @y + ' <Type>PAYMENT</Type>'
select @y = @y + ' <CashType>CHECK</CashType>'
select @y = @y + ' <Description />'
select @y = @y + ' <CheckNumber />'
select @y = @y + ' <Amount>3.00000</Amount>'
select @y = @y + ' <AppliedAmount>3.00000</AppliedAmount>'
select @y = @y + ' <UnappliedAmount>0.00000</UnappliedAmount>'
select @y = @y + ' <Items />'
select @y = @y + '</Receivable>'
select @x = @y
--SQL 2000 CODE
-- Initialize XML handle
DECLARE @hdoc INT
EXEC sp_xml_preparedocument @hdoc OUTPUT, @x
-- select the records
SELECT x.documentNumber
FROM OPENXML ( @hdoc, '/Receivable', 1 ) WITH (
documentNumber VARCHAR(20) '@documentNumber'
) AS x
-- Release XML handle
EXEC sp_xml_removedocument @hdoc
--SQL 2005 CODE
SELECT
x.header.value('@documentNumber[1]', 'varchar(20)') AS OrderNumber,
x.header.value('Type[1]', 'varchar(20)') AS Typex2
FROM @x.nodes('//Receivable') AS x(header)