Monday, July 23, 2012

SQL parse string

To parse a value from a column, PARSENAME and REPLACE can be used. 
For instance, if the variable portion of a URL needs to be parsed, it can be done like this:

SELECT PARSENAME(REPLACE('http://www.theurl.com?var=1234', 'var=', '.'), 1) //Returns 1234