I'm using SQL Server 2008 R2.
I have a table with a xml data type column. I'm trying to query one of the elements from the column's value, but getting the following error:
Msg 2389, Level 16, State 1, Line 12
XQuery [tblEmailFollowup.OptionalParameters.value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
What am I doing wrong?
Thanks for the help.
I have a table with a xml data type column. I'm trying to query one of the elements from the column's value, but getting the following error:
Msg 2389, Level 16, State 1, Line 12
XQuery [tblEmailFollowup.OptionalParameters.value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
SQL:
CREATE TABLE tblEmailFollowup
(
EmailFollowupID int IDENTITY(1,1)
,OptionalParameters xml
)
DECLARE @Parameter XML
SET @Parameter = '<Parameter><UserType>DonorManager</UserType></Parameter>'
INSERT INTO tblEmailFollowup(OptionalParameters)Values(@Parameter)
SELECT ref.value('UserType', 'nvarchar(50)') AS [UserType]
FROM tblEmailFollowup
CROSS APPLY OptionalParameters.nodes('//Parameter') R(ref)
What am I doing wrong?
Thanks for the help.