patternsqlMinor
Remove Dot at end of line of the string in SQLserver
Viewed 0 times
thelinesqlserverdotremoveendstring
Problem
I would to like to remove the dot at end of the line alone if exists in the string in SQL server.
Example:
Required output:
Example:
ABC Private's co., ltd.Required output:
ABC Private's co., ltdSolution
You can use
like to check for a . at the end of the string.declare @S nvarchar(max) = 'ABC Private''s co., ltd.';
select case when @S like '%.'
then left(@S, len(@S) - 1)
else @S
end;Code Snippets
declare @S nvarchar(max) = 'ABC Private''s co., ltd.';
select case when @S like '%.'
then left(@S, len(@S) - 1)
else @S
end;Context
StackExchange Database Administrators Q#185571, answer score: 6
Revisions (0)
No revisions yet.