patternsqlMinor
String parsing: Extracting the filename from a URL
Viewed 0 times
thefilenameparsingextractingfromstringurl
Problem
This is a link I have in a column of a table:
There are like 1000's of rows like this.
I am new to SQL Server.
http://earthexplorer.usgs.gov/browse/etm/1/11/2000/LE70010112000130KIS00.jpgThere are like 1000's of rows like this.
- Is it possible to extract the FileName like
LE70010112000130KIS00(without the path and filename extension) and put it in another column?
I am new to SQL Server.
Solution
I used this code to extract the FileName with Extension.
And this code to extract and update only FileName
UPDATE TableName set ColumnName= right(Image_Link, CHARINDEX('/', REVERSE(ColumnName) + '/') - 1)And this code to extract and update only FileName
UPDATE TableName SET ColumnName= REVERSE(SUBSTRING(REVERSE(ColumnName),CHARINDEX('.', REVERSE(ColumnName)) + 1, 999))Code Snippets
UPDATE TableName set ColumnName= right(Image_Link, CHARINDEX('/', REVERSE(ColumnName) + '/') - 1)UPDATE TableName SET ColumnName= REVERSE(SUBSTRING(REVERSE(ColumnName),CHARINDEX('.', REVERSE(ColumnName)) + 1, 999))Context
StackExchange Database Administrators Q#127794, answer score: 3
Revisions (0)
No revisions yet.