Sql-server – Remove Dot at end of line of the string in SQLserver

sql servert-sql

I would to like to remove the dot at end of the line alone if exists in the string in SQL server.

Example:

ABC Private's co., ltd. 

Required output:

ABC Private's co., ltd

Best Answer

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;