Thursday, 19 October 2017

TrimString Scaler Valued Function

ALTER FUNCTION [dbo].[TrimString](@string NVARCHAR(MAX),@TrimLength INT=0)
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @Result NVARCHAR(MAX);
SELECT @Result =  CASE WHEN (LEN(ISNULL(LTRIM(RTRIM(@string)),''))> @TrimLength)
THEN  '<span title="'+@string+'">'+ISNULL(SUBSTRING(ISNULL(LTRIM(RTRIM(@string)),''),0,@TrimLength),'')+'..</span>'
  ELSE ISNULL(LTRIM(RTRIM(@string)),'')
  END
RETURN @Result

END

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...