You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/t-sql/xml/delete-xml-dml.md
+49-49Lines changed: 49 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,8 +25,7 @@ ms.author: genemi
25
25
26
26
## Syntax
27
27
28
-
```
29
-
28
+
```syntaxsql
30
29
delete Expression
31
30
```
32
31
@@ -41,8 +40,8 @@ delete Expression
41
40
### A. Deleting nodes from a document stored in an untyped xml variable
42
41
The following example illustrates how to delete various nodes from a document. First, an XML instance is assigned to variable of **xml** type. Then, subsequent delete XML DML statements delete various nodes from the document.
43
42
44
-
```
45
-
DECLARE @myDoc xml
43
+
```sql
44
+
DECLARE @myDoc XML
46
45
SET @myDoc ='<?Instructions for=TheWC.exe ?>
47
46
<Root>
48
47
<!-- instructions for the 1st work center -->
@@ -83,9 +82,9 @@ SELECT @myDoc
83
82
### B. Deleting nodes from a document stored in an untyped xml column
84
83
In the following example, a **delete** XML DML statement removes the second child element of <`Features`> from the document stored in the column.
In the example, you first create a table (T) with a typed **xml** column in the AdventureWorks database. You then copy a manufacturing instructions XML instance from the Instructions column in the ProductModel table into table T and delete one or more nodes from the document.
119
118
120
-
```
121
-
use AdventureWorks
122
-
go
123
-
drop table T
124
-
go
125
-
create table T(ProductModelID int primary key,
126
-
Instructions xml (Production.ManuInstructionsSchemaCollection))
127
-
go
128
-
insert T
129
-
select ProductModelID, Instructions
130
-
from Production.ProductModel
131
-
where ProductModelID=7
132
-
go
133
-
select Instructions
134
-
from T
119
+
```sql
120
+
USE AdventureWorks
121
+
GO
122
+
DROPTABLE T
123
+
GO
124
+
CREATETABLET(
125
+
ProductModelID INTPRIMARY KEY,
126
+
Instructions XML (Production.ManuInstructionsSchemaCollection))
127
+
GO
128
+
INSERT T
129
+
SELECT ProductModelID, Instructions
130
+
FROMProduction.ProductModel
131
+
WHERE ProductModelID =7
132
+
GO
133
+
SELECT Instructions
134
+
FROM T
135
135
--1) insert <Location 1000/>. Note: <Root> must be singleton in the query
0 commit comments