LTRIM,RTRIM,LEFT ,RIGHT AND SUBSTRING FUNCTIONS IN SQL



Ltrim and Rtrim simply remove spaces from string on the Right and Left

SELECT * FROM SampleTable WHERE LTRIM(RegNo)='String'

SELECT * FROM SampleTable WHERE RTRIM(RegNo)='String'



LEFT ,RIGHT AND SUBSTRING  FUNCTIONS IN SQL

SELECT LEFT('HELLO WORLD',6)  --OUT PUT HELLO

SELECT RIGHT('HELLO WORLD',5) --OUT PUT WORLD

SELECT SUBSTRING('HELLO WORLD',1,5) --OUT PUT HELLO 

SELECT SUBSTRING('HELLO WORLD',7,11) --OUT PUT WORLD

No comments:

Post a Comment