
- SQL - Home
- SQL - Roadmap
- SQL - Overview
- SQL - RDBMS Concepts
- SQL - Databases
- SQL - Syntax
- SQL - Data Types
- SQL - Operators
- SQL - Expressions
- SQL - Comments
- SQL Database
- SQL - Create Database
- SQL - Drop Database
- SQL - Select Database
- SQL - Rename Database
- SQL - Show Databases
- SQL - Backup Database
- SQL Table
- SQL - Create Table
- SQL - Show Tables
- SQL - Rename Table
- SQL - Truncate Table
- SQL - Clone Tables
- SQL - Temporary Tables
- SQL - Alter Tables
- SQL - Drop Table
- SQL - Delete Table
- SQL - Constraints
- SQL Queries
- SQL - Insert Query
- SQL - Select Query
- SQL - Select Into
- SQL - Insert Into Select
- SQL - Update Query
- SQL - Delete Query
- SQL - Sorting Results
- SQL Views
- SQL - Create Views
- SQL - Update Views
- SQL - Drop Views
- SQL - Rename Views
- SQL Operators and Clauses
- SQL - Where Clause
- SQL - Top Clause
- SQL - Distinct Clause
- SQL - Order By Clause
- SQL - Group By Clause
- SQL - Having Clause
- SQL - AND & OR
- SQL - BOOLEAN (BIT) Operator
- SQL - LIKE Operator
- SQL - IN Operator
- SQL - ANY, ALL Operators
- SQL - EXISTS Operator
- SQL - CASE
- SQL - NOT Operator
- SQL - NOT EQUAL
- SQL - IS NULL
- SQL - IS NOT NULL
- SQL - NOT NULL
- SQL - BETWEEN Operator
- SQL - UNION Operator
- SQL - UNION vs UNION ALL
- SQL - INTERSECT Operator
- SQL - EXCEPT Operator
- SQL - Aliases
- SQL Joins
- SQL - Using Joins
- SQL - Inner Join
- SQL - Left Join
- SQL - Right Join
- SQL - Cross Join
- SQL - Full Join
- SQL - Self Join
- SQL - Delete Join
- SQL - Update Join
- SQL - Left Join vs Right Join
- SQL - Union vs Join
- SQL Keys
- SQL - Unique Key
- SQL - Primary Key
- SQL - Foreign Key
- SQL - Composite Key
- SQL - Alternate Key
- SQL Indexes
- SQL - Indexes
- SQL - Create Index
- SQL - Drop Index
- SQL - Show Indexes
- SQL - Unique Index
- SQL - Clustered Index
- SQL - Non-Clustered Index
- Advanced SQL
- SQL - Wildcards
- SQL - Injection
- SQL - Hosting
- SQL - Min & Max
- SQL - Null Functions
- SQL - Check Constraint
- SQL - Default Constraint
- SQL - Stored Procedures
- SQL - NULL Values
- SQL - Transactions
- SQL - Sub Queries
- SQL - Handling Duplicates
- SQL - Using Sequences
- SQL - Auto Increment
- SQL - Date & Time
- SQL - Cursors
- SQL - Common Table Expression
- SQL - Group By vs Order By
- SQL - IN vs EXISTS
- SQL - Database Tuning
- SQL Function Reference
- SQL - Date Functions
- SQL - String Functions
- SQL - Aggregate Functions
- SQL - Numeric Functions
- SQL - Text & Image Functions
- SQL - Statistical Functions
- SQL - Logical Functions
- SQL - Cursor Functions
- SQL - JSON Functions
- SQL - Conversion Functions
- SQL - Datatype Functions
- SQL Useful Resources
- SQL - Questions and Answers
- SQL - Cheatsheet
- SQL - Quick Guide
- SQL - Useful Functions
- SQL - Useful Resources
- SQL - Discussion
SQL - TEXTPTR() Function
The SQL TEXTPTR() function is used to retrieve the pointer value of the text or images.
It accepts column as a parameter and returns a 16-byte pointer value of the current text, ntext, or images. A text pointer value is a unique varbinary(16-byte) value that indicates each text, ntext, or images column in each row in which LOB(large objects is a set of data types for storing large amounts of unstructured or semi-structured data) you are working with.
The retrieved text pointer value can be used to read, write, or update the existing text statements.
Syntax
Following is the syntax of the SQL TEXTPTR() function −
TEXTPTR ( column )
Parameters
column − It is a text, ntext, or image from which the pointer value will be retrieved.
Return value
This function returns the pointer value of the text or images.
Example
If we pass the NTEXT datatype column of a table as an argument to the TEXTPTR() function, it will return the column's content pointer value.
Assume we have created a table with the name Customers using the CREATE statement as follows −
CREATE TABLE CUSTOMERS( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (25) , SALARY DECIMAL (18, 2), PIN NTEXT, CITY TEXT);
Now, let's insert some record into the Customers table using the INSERT statement as follows −
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY, PIN, CITY) VALUES (1, 'Ramesh', 32, 'Ahmedabad', 2000.00, '380001', 'Jamalpur'); INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY, PIN, CITY) VALUES (2, 'Khilan', 25, 'Delhi', 1500.00,'110006','Chandni Chowk' ); INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY, PIN, CITY) VALUES (3, 'kaushik', 23, 'Kota', 2000.00,'325001', 'Aamli'); INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY, PIN, CITY) VALUES (4, 'Chaitali', 25, 'Mumbai', 6500.00,'400002', 'Kalbadevi' );
The following SQL query retieves the pointer value of the content of the column PIN(NTEXT) in the Customers table −
SELECT TEXTPTR(PIN) AS POINTER_VALUE FROM CUSTOMERS;
Output
The above SQL query produces the following output −
+------------------------------------+ | POINTER_VALUE | +------------------------------------+ | 0xFEFFA10F00000000DA01000001000000 | | 0xFEFFA30F00000000DA01000001000200 | | 0xFEFFA50F00000000DA01000001000400 | | 0xFEFFA70F00000000DA01000001000600 | +------------------------------------+
Example
You can also pass the TEXT datatype column of a table as an argument to this function, it will return the pointer value of the content of the columns.
Considering the above Customers table, the CITY column is created with the datatype TEXT, so now let's pass the CITY column as an argument to the TEXTPTR() function to retrieve the pointer value of the content of the column.
The following SQL query retrieves the pointer value of the content of the column CITY(TEXT) in the Customers table −
SELECT TEXTPTR(CITY) AS POINTER_VALUE_OF_TEXT FROM CUSTOMERS;
Output
+------------------------------------+ | POINTER_VALUE_OF_TEXT | +------------------------------------+ | 0xFDFFA20F00000000DA01000001000100 | | 0xFDFFA40F00000000DA01000001000300 | | 0xFDFFA60F00000000DA01000001000500 | | 0xFDFFA80F00000000DA01000001000700 | +------------------------------------+
Example
If we pass the VARCHAR datatype column as an argument to this function, it will throw an error.
In the following example, we are passing the column NAME(datatype varchar) as an argument to the TEXTPTR() function to retrieve the pointer value of the column content.
SELECT TEXTPTR(NAME) AS POINTER_VALUE_OF_TEXT FROM CUSTOMERS;
Output
On executing the above statement, it produces the following output −
Argument data type varchar is invalid for argument 1 of textptr function.