Afternoon Everyone,

I'm trying to use a variable to set the singleton value in the below XML:

Code:
	set @singleton = '2'
	
	set @Part_No = @xmlMsg.value('(/MSLIOrderResponsexCBL35Target/OrderResponseDetail/ListOfOrderResponseItemDetail/OrderResponseItemDetail/ItemDetailChanges/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/SellerPartNumber/PartNum/PartID)[@vari=sql:variable("@singleton")]','varchar(50)') --Can Increment
	
	Print @Part_No
I'm getting the error below:

XQuery [value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'

I guess its not picking up the variable I'm using. If I set it this way:

Code:
set @Part_No = 	@xmlMsg.value('(/MSLIOrderResponsexCBL35Target/OrderResponseDetail/ListOfOrderResponseItemDetail/OrderResponseItemDetail/ItemDetailChanges/ItemDetail/BaseItemDetail/ItemIdentifiers/PartNumbers/SellerPartNumber/PartNum/PartID)['+@singleton+']','varchar(100)') as PartID
It complaims about a string literal. does anyone have any examples of doing this or can help me out?

Cheers,

Matt