a
 
SQLRef.Com 

            SqlRef.Com


SQL BASIC
DATA QUERY LANGUAGE
BASIC FUNCTION
AGGREGATE FUNCTION
DATA MANIPULATION LANGUAGE
DATA DEFINITION LANGUAGE
DATA CONTROL LANGUAGE
OTHERS

REPLACE()

The REPLACE function will searches the character string for a particular character string and replace it with a specified character string. The general syntax for REPLACE function is as follow. 

SELECT REPLACE (<column_name>, search_string, replacement_string) FROM <table_name>

The following SQL statement replaces all hyphens in Telephone  column of Customers table with dots (.).

SELECT REPLACE(Telephone, '-', '.') AS New_Phone_No FROM Customers

Table: Customers
CustID Name Address City Country PostalCode Telephone Fax
CUST001 Maria Anders Obere Str. 57 Berlin Germany 12209 030-0074321 030-0076545
CUST002 Ernst Handel Kirchgasse 6 Graz Austria 8010 7675-3425 7675-3426
CUST003 Helen Bennett Garden House Crowther Way Cowes UK PO31 7PJ (198) 555-8888 (198) 555-8889
CUST004 Paula Wilson 2817 Milton Dr. Albuquerque USA 87110 (505) 555-5939 (505) 555-5940
CUST005 Liu Wong 55 Grizzly Peak Rd. Butte USA 59801 (406) 555-5834 (406) 555-8083

Resultset 1

CustID Name Address City Country PostalCode Telephone Fax
CUST001 Maria Anders Obere Str. 57 Berlin Germany 12209 030-0074321 030. 0076545
CUST002 Ernst Handel Kirchgasse 6 Graz Austria 8010 7675-3425 7675. 3426
CUST003 Helen Bennett Garden House Crowther Way Cowes UK PO31 7PJ (198) 555-8888 (198) 555. 8889
CUST004 Paula Wilson 2817 Milton Dr. Albuquerque USA 87110 (505) 555-5939 (505) 555. 5940
CUST005 Liu Wong 55 Grizzly Peak Rd. Butte USA 59801 (406) 555-5834 (406) 555. 8083


 
| Freebies | Free Trial | Add to Bookmark | Search | Link to Us |
Copyright © 2006 SqlRef.com. All rights reserved.