QUOTE_IDENT()
functionThe QUOTE_IDENT()
function returns the provided string as a string enclosed in double quotation marks, allowing it to be used as an identifier in a SQL statement.
QUOTE_IDENT(string)
string
: This represents the input string. It can be char or varchar.The following code demonstrates how to use the QUOTE_IDENT()
function in SQL.
CREATE TABLE Employee ( id int, first_name varchar(50), last_name varchar (50), salary int, gender varchar(10), state varchar(15) ); -- Insert data INSERT INTO Employee VALUES (01,'Sharon', 'Peller',40000,'F','Kogi'); INSERT INTO Employee VALUES (02,'Paul', 'Dons',150000,'M','Lagos'); INSERT INTO Employee VALUES (03,'Ameera', 'Abedayo',200000,'F','Imo'); INSERT INTO Employee VALUES (04,'Maria', 'Elijah',320000,'F','Lagos'); INSERT INTO Employee VALUES (05,'David', 'Hassan',250000,'M','Abuja'); INSERT INTO Employee VALUES (06,'Niniola', 'Disu',80000,'F','Lagos'); INSERT INTO Employee VALUES (08,'Joe', 'Smith',75000, 'M','Lagos'); -- Query SELECT first_name,QUOTE_IDENT(gender) FROM Employee ORDER BY first_name;
In the code above:
Employee
which has the columns id
, name
, salary
, gender
, and state
.Employee
table.QUOTE_IDENT()
function, we return a double-quoted string for the gender
column and we order the query using the first_name
column.RELATED TAGS
CONTRIBUTOR
View all Courses