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/functions/text-and-image-functions-textptr-transact-sql.md
+9-10Lines changed: 9 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,7 @@ ms.author: jrasnick
34
34
35
35
## Syntax
36
36
37
-
```
38
-
37
+
```syntaxsql
39
38
TEXTPTR ( column )
40
39
```
41
40
@@ -72,10 +71,10 @@ TEXTPTR ( column )
72
71
### A. Using TEXTPTR
73
72
The following example uses the `TEXTPTR` function to locate the **image** column `logo` associated with `New Moon Books` in the `pub_info` table of the `pubs` database. The text pointer is put into a local variable `@ptrval.`
74
73
75
-
```
74
+
```sql
76
75
USE pubs;
77
76
GO
78
-
DECLARE @ptrval varbinary(16);
77
+
DECLARE @ptrval VARBINARY(16);
79
78
SELECT @ptrval = TEXTPTR(logo)
80
79
FROM pub_info pr, publishers p
81
80
WHEREp.pub_id=pr.pub_id
@@ -86,8 +85,8 @@ GO
86
85
### B. Using TEXTPTR with in-row text
87
86
In [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], the in-row text pointer must be used inside a transaction, as shown in the following example.
88
87
89
-
```
90
-
CREATE TABLE t1 (c1 int, c2 text);
88
+
```sql
89
+
CREATETABLEt1 (c1 INT, c2 TEXT);
91
90
EXEC sp_tableoption 't1', 'text in row', 'on';
92
91
INSERT t1 VALUES ('1', 'This is text.');
93
92
GO
@@ -103,7 +102,7 @@ COMMIT;
103
102
### C. Returning text data
104
103
The following example selects the `pub_id` column and the 16-byte text pointer of the `pr_info` column from the `pub_info` table.
105
104
106
-
```
105
+
```sql
107
106
USE pubs;
108
107
GO
109
108
SELECT pub_id, TEXTPTR(pr_info)
@@ -131,7 +130,7 @@ pub_id
131
130
132
131
The following example shows how to return the first `8000` bytes of text without using TEXTPTR.
133
132
134
-
```
133
+
```sql
135
134
USE pubs;
136
135
GO
137
136
SET TEXTSIZE 8000;
@@ -162,10 +161,10 @@ This is sample text data for Lucerne Publishing, publisher 9999 in the pubs data
162
161
### D. Returning specific text data
163
162
The following example locates the `text` column (`pr_info`) associated with `pub_id``0736` in the `pub_info` table of the `pubs` database. It first declares the local variable `@val`. The text pointer (a long binary string) is then put into `@val` and supplied as a parameter to the `READTEXT` statement. This returns 10 bytes starting at the fifth byte (offset of 4).
0 commit comments