Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Expand TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Expand Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Expand CursorCursor
Expand OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Expand Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Expand v.IMP Queriesv.IMP Queries
Expand XMLXML
Collapse Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Expand CreateCreate
     

Use LIKE instead of SUBSTRING

 
      
Continents
Country Continent
India Asia
USA N.America
Italy Europe
---- Low Performance by using SUBSTRING
SELECT * FROM Continents WHERE SUBSTRING(Country,1,1) = 'I'
---- High Performance by using LIKE
SELECT * FROM Continents WHERE Country LIKE 'I%'
---- both Queries will give the same output but Performance is different, if the data is tooooo big
      
Output
Country Continent
India Asia
Italy Europe