SQL Trim Function, SQL Tutorial, Global Guide Line Technology.
Bookmark Bookmark: SQL Trim Function, SQL Tutorial Forum | Directory | Blog |

      Home                    

Basic SQL Guide.           
SQL Introduction.               
 What is Table?                  
 SQL Create Table.            
 SQL Insert Statement.      
 SQL Select Keyword.        
 SQL Order by clause.        
 SQL Count Statement.      
 SQL Group By Clause.      
 SQL Having Clause.          
 SQL Alias Tables.             
 SQL Join Tables.              
 SQL Outer Join.               
 SQL Update Statement.   
 SQL Delete Statement.    
 SQL Distinct Keyword.      
 SQL Where Keyword.       
 SQL And Or Keyword.      
 SQL In Keyword.              
 SQL Between Keyword.   
 SQL Like Keyword.          
 SQL Functions.                
 SQL Concatenate.           
 SQL Substrings.               
 SQL Trim Function.
 SQL Constraints.              
 SQL Primary Key.            
 SQL Foreign Key.            
 SQL Cerate Views.           
 SQL Create Index.           
 SQL Alter Table.             
 SQL Drop Table.             
 SQL Truncate Table.      
 SQL Summary.                


Submit your link

SQL Tutorial >> SQL Trim Function.


     Back             Next     



Now SQL Tutorial will explain the SQL TRIM function,  in SQL Trim Function is used to remove specified prefix or suffix from a string. The most common pattern being removed is white spaces. This function is called in different ways with all the major databases such as Oracle, MySQL and MS SQL Server.

Syntax for SQL Trim Function


MySQL Syntax     : TRIM(), RTRIM(), LTRIM() 

Oracle Syntax    : RTRIM(), LTRIM() 

SQL Server Syntax: RTRIM(), LTRIM() 


The syntax for these trim functions in query analyzer is as under.

TRIM([[LOCATION] [remstr] FROM ] str):

[LOCATION] can be either LEADING, TRAILING, or BOTH. This function gets rid of the [remstr] pattern from either the beginning of the string or the end of the string, or both. If no [remstr] is specified, white spaces are removed.

LTRIM(str):

Removes all white spaces from the beginning of the string.

RTRIM(str):

Examples of SQL Trim Function

Removes all white spaces at the end of the given string.

Example of SQL TRIM Function.

SELECT TRIM('      Sample     ');

Result of SQL Trim Function Example

'Sample'

Example of SQL LTRIM Function.

SELECT LTRIM('      Sample      ');

Result of SQL LTRIM Function Example

'Sample      '

Example of SQL RTRIM Functiom

SELECT RTRIM('      Sample      ');

Result of SQL RTRIM Function Example

'      Sample'

     Back             Next     
 

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2014 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 1090 visitors are online now