Sunday, July 8, 2012

How to use substring and len function in sql server 2005 or 2008

I am giving one example from that you will understand How to use Substring and Len Funcation.
Suppose I have one table employee with 1000 of Record. and Having one Column Name is stImage.
This column contain link of Image. stImage contain data like http://www.example.com/images/sqlserversubstring.jpg now I want to change only domain name only replace with http://aspdotnet-example.com/images/sqlserversubstring.jpg for that we will do
update employee set stImage= 'http://aspdotnet-example.com'+
SUBSTRING(stImage,len('http://www.example.com'),len(stImage))
from employee

ASPdotNET-Example