ppetyr
ppetyr

Reputation: 111

How to get characters at given positions from nvarchar value in sql

I encountered with the following problem: I have a column of type nvarchar called "CaseFullNumber" which contains 14 digits. I need to take the 8th and 9th digits of that number and to perform other actions according to this if these two characters are "01" or "02" (they can be only "01" and "02"). I suppose there is a sql function which accomplishes this task but after research in google and stackoverflow I did not find any. Can anyone help me with this?

Upvotes: 0

Views: 995

Answers (1)

Siyual
Siyual

Reputation: 16917

You can use SUBSTRING() for this:

Select SubString(CaseFullNumber, 8, 2)

This pulls two characters starting at the 8th position in CaseFullNumber.

Upvotes: 1

Related Questions