MID Function in SQL 2012

In this article I am going to explain how to use MID function in sql 2012.
  • 3297

Introduction

This function is used when we want to extract some characters from a given column.

Syntax

SELECT MID(column_name, start, length) from table_name

where,

column_name- specifies that column name whose characters you want to extract
start- specifies the starting position.
length- It is optional, it specifies number of characters to return.

Example

Suppose we have a table named "Employee" given in following image.

CreateTable-in-sqlserver.jpg

Extract first four characters from F_Name. Type following

SELECT MID(F_Name,1,4) as Name FROM Employee

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.