What's the equivalent of the EXCEL MID FUNCTION SQL Server 2008

Hi Experts,
I have the following function in EXCEL (see below), how can I write this same function in SQL Server 2008 R2?
I don't believe there is a MID function in SQL.  What do I use instead?


Thank you very much in advance,
Who is Participating?
Lokesh B RDeveloperCommented:

You can use SUBSTRING in SQL.

(SUBSTRING(C4,1,1)*3)+(SUBSTRING(C4,2,1)) + (SUBSTRING(C4,3,1)*3)+(SUBSTRING(C4,4,1))+(SUBSTRING(C4,5,1)*3)+(SUBSTRING(C4,6,1))+(SUBSTRING(C4,7,1)*3)+(SUBSTRING(C4,8,1))+(SUBSTRING(C4,9,1)*3)+(SUBSTRING(C4,10,1))+(SUBSTRING(C4,11,1)*3)+(SUBSTRING(C4,12,1))+(SUBSTRING(C4,13,1)*3)+(SUBSTRING(C4,14,1))+(SUBSTRING(C4,15,1)*3)+(SUBSTRING(C4,16,1))+(SUBSTRING(C4,17,1)*3)

Open in new window

Vitor MontalvãoMSSQL Senior EngineerCommented:
mainrotor, do you still need help on this question?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.