INITCAP() functionThe INITCAP() function converts the first character of each string to upper case and the remaining characters to lower case.
INITCAP(string)
string: This represents the string to be altered.The following code shows how to use the INITCAP() function in SQL:
CREATE TABLE Product (id int,product_name varchar(50),price varchar(50),product_id varchar (20));-- Insert dataINSERT INTO ProductVALUES (101,'t-shirt','$100','boo-01-345');INSERT INTO ProductVALUES (102,'hand Bag','$65','boo-01-238');INSERT INTO ProductVALUES (103,'ipad','$1200','boo-01-103');INSERT INTO ProductVALUES (104,'cereal','$30','boo-01-775');INSERT INTO ProductVALUES (105,'microwave','$520','boo-01-788');INSERT INTO ProductVALUES (106,'cloth clips','$15','boo-01-924');INSERT INTO ProductVALUES (108,'zara Perfume','$120','boo-01-245');-- QuerySELECT id, product_name, INITCAP(product_name) AS new_product_nameFROM Product;
Product that has the id, product_name, price, and book_id columns.id, and product_name columns. We then use the INITCAP() function to alter the first character of each product name to uppercase and store it in a new column, new_product_name.