harsha547
4/2/2017 - 3:09 PM

Find the records if there is alteast one space between name EX : HARSHA VARDHAN is valid

Find the records if there is alteast one space between name EX : HARSHA VARDHAN is valid

-- find the records if there is alteast one space between name EX : HARSHA VARDHAN is valid

-- Because, there is a space between harsha and vardhan

CREATE TABLE #employee
(
 ID INT,
 Name VARCHAR(45)
);

INSERT INTO #employee VALUES(1,' Harsha ');
INSERT INTO #employee VALUES(1,'Harsha Vardhan');
INSERT INTO #employee VALUES(1, ' Gautam Gambhir');
INSERT INTO #employee VALUES(1, 'Gambhir ');

SELECT Name 
       From #employee
	   WHERE LEN(RTRIM(LTRIM(Name))) - LEN(REPLACE(RTRIM(LTRIM(Name)),' ','')) >= 1  ; 

   
   
   -- Linkedin Profile : https://www.linkedin.com/in/harshasannareddy/