/***************************Test Table Creation************************/
CREATE TABLE [dbo].[TestTable](
[RowID] [int] IDENTITY(1,1) NOT NULL,
[RowName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Data] [xml] NULL,
CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED
(
[RowID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
/*********************************************************************/
/***************************Insert Values*****************************/
Declare @Request As XML
Set @Request = '
hohohoho
'
Insert Into TestTable
(
RowName
,Data
)
Values (
'Row 1 Data'
,@Request
)
Set @Request = '
hohohoho
'
Insert Into TestTable
(
RowName
,Data
)
Values (
'Row 2 Data'
,@Request
)
Set @Request = '
hohohoho
'
Insert Into TestTable
(
RowName
,Data
)
Values (
'Row 3 Data'
,@Request
)
/*********************************************************************/
/***************************Select Logic *****************************/
/*Dont perform 'modify' in the select statement. Instead get the whole xml in a variable and the do the 'modify' thingy*/
Set @Request = (
Select RowID
,RowName
,Data
From TestTable
For XML Auto,Root('RootData')
)
Set @Request.modify('delete (//Properties/Cultures/Culture[@cultureName != "en-GB"])')
/*Get the data in XML format*/
Select @Request
/*Get the data in tabular format*/
Select A.B.value('@RowID', 'Int') As RowID
,A.B.value('@RowName', 'Varchar(50)')
,A.B.query('*')
From @Request.nodes('//RootData/TestTable') A(B)
/*********************************************************************/
|