Blog Archives

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

SQL – Character Index

CHARACTER INDEX SQL Server SELECT CHARINDEX(‘WORD’, ‘FIND WORD IN THIS SENTENCE.’) Returns 6 (WORD starts in the 6th position of the sentence.) Oracle SELECT INSTR(‘FIND WORD IN THIS SENTENCE’, ‘WORD’) FROM DUAL; Returns 6 (WORD starts in the 6th position

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

SQL NULLIF Function

NULLIF FUNCTION: Compares two values and does the following: Returns null if both values are the same. Returns the first value if both values are different. SQL Server: Select NULLIF(FIELD1, FIELD2) AS FIELD3 FROM TABLE; Oracle: Select NULLIF(FIELD1, FIELD2) AS

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