RTRIM() Function in SQL Server
The RTRIM() function removes trailing spaces from a string.
Syntax :
RTRIM(input_string)
Parameter :
RTRIM() function accepts single-parameter like input_string.
- input_string :
It is an expression of character or binary data. It can be a literal string, variable, or column.
Returns – It returns a string after truncating all trailing blanks.
Example-1 :
Using RTRIM() function with literal strings.
SELECT RTRIM('GFG a computer science portal for Beginner') AS RightTrimmedString;
Output :
RightTrimmedString |
GFG a computer science portal for Beginner |
Example-2 :
Using RTRIM() function with a variable.
DECLARE @input_string varchar(25); SET @input_string = 'IPL sponsorship this year.'; SELECT RTRIM(@input_string) + ' Dream11 ';
Output :
IPL sponsorship this year Dream11
Example-3 :
You can used RTRIM() function with a variable for question and answer as shown in example given below.
DECLARE @input_string varchar(25); SET @input_string = 'who is the sponsor for IPL Game this year :'; SELECT RTRIM(@input_string)+'Dream11' ;
Output :
who is the sponsor for IPL Game this year :Dream11
Contact Us