T-SQL Tutorial

SQL Mid


Mid Syntax:

SELECT MID(column_name,start[,length])
FROM table_name

Students table:

IDNAMEState
1TomArizona
2LindaTexas
3HelenFlorida
4RobertCalifornia

Mid Example:

SELECT state, MID(state,1,4)
FROM students;

Mid Result:

StateMID(state,1,3)
ArizonaAri
TexasTex
FloridaFlo
CaliforniaCal