Blog Archives

SQL – Replace Statement

REPLACE STATEMENT The Replace Statement replaces all instances of a specified string value with a new value. Syntax: REPLACE(Field Name, Search String, New String) SQL Server: SELECT REPLACE(FIELD1,’/’,’-‘) FROM TABLE Oracle: SELECT REPLACE(FIELD1,’/’,’-‘) FROM TABLE;  

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Character Case Functions

Character Function – Returns the Character from a given character code SQL Server SELECT CHAR(65) + CHAR(66) + CHAR(67) Returns ABC Oracle: SELECT CHR(65) || CHR(66) || CHR(67) FROM dual; Returns ABC  

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Char Function

Character Function – Returns the Character from a given character code SQL Server SELECT CHAR(65) + CHAR(66) + CHAR(67) Returns ABC Oracle: SELECT CHR(65) || CHR(66) || CHR(67) FROM dual; Returns ABC  

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Concatenate

Concatenate Note, when joining two or more fields together, both fields must be a string value. If one of the fields is a numeric value, the numeric field must be converted to a string. SQL Server: SELECT Emp_LastName + ‘,

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Length Function

LENGTH FUNCTION The length function returns an integer value representing the length of the selected field or given value. SQL Server SELECT LEN(‘WORD’) Returns 4 Oracle SELECT LENGTH(‘WORD’) FROM DUAL; Returns 4  

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Reverse Function

REVERSE FUNCTION If for some reason, you need to reverse the direction of characters or numbers in a field, you can use the reverse function. SQL Server SELECT REVERSE(‘WORD’) Returns ‘DROW’ Oracle SELECT REVERSE(‘WORD’) FROM DUAL; Returns ‘DROW’  

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Substring Function

SUBSTRING FUNCTION Return a portion of a selected string. SQL Server Syntax – SUBSTRING(string, starting position, ending position) SELECT SUBSTRING(‘WORD’,1,2) Returns ‘WO’ Oracle Syntax – SUBSTRING(string, starting position, ending position) SELECT SUBSTR(‘WORD’,1,2) Returns ‘WO’  

Tagged with: , , , ,
Posted in Oracle, SQL Server