Sunday, 28 July 2024

SQL Function to Remove All Spaces From String

 USE [ADN-TECHNOLOGIES-LIMITED-STAGING]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- =============================================

-- Author: Vivek Nigam [ADN TECHNOLOGIES LIMITED]

-- Created date: 15-January-2020 @ 09:24 AM

-- Description: Sql Function  to Remove_All_Spaces From String

--- File Name - Fn_07_Function_To_Remove_All_Spaces.sql

--- fn_RemoveAllSpaces

-- Modified By  :  Vivek Nigam [ADN TECHNOLOGIES LIMITED]

-- Modify On -               

-- =============================================

--Check if a function exists in Database Before Creating - If exists Then Drop 

  IF object_id('dbo.fn_RemoveAllSpaces') IS NOT NULL

BEGIN

DROP FUNCTION [dbo].fn_RemoveAllSpaces

END

GO


CREATE FUNCTION fn_RemoveAllSpaces

(

@InputStr VARCHAR(100)

)

RETURNS VARCHAR(100)

AS

BEGIN

DECLARE @ResultStr varchar(8000)

SET @ResultStr = @InputStr

WHILE CHARINDEX(' ', @ResultStr) > 0

SET @ResultStr = REPLACE(@InputStr, ' ', '')


RETURN @ResultStr

END

No comments:

Post a Comment

Z_KOMGG_HERO_CUS - SAP DATA EXTRACT USING ABAP PROGRAM

 *&---------------------------------------------------------------------* *& Report  Z_KOMGG_HERO_CUS *& *&-----------------...