Saturday, April 14, 2012

Dynamic SUBSTRING() in MS SQL

My requirement is to use the SUBSTRING() dynamically in SQL query.
I have the set of data in a table. I want to pick only the last 6 digits.


General syntax of the SUBSTRING function
SUBSTRING ( expression ,start , length )
I'm using below query according to my requirement.

SELECT SUBSTRING(VALUE,LEN(VALUE)-6+1,LEN(VALUE)+1) FROM TEST




2 comments: