Hello,
I want to return a row from a table through sql. Now the row returns this:
3/1573/ImageName.jpg
I want to return it like this:
1573/ImageName.jpg
I am using SQL Server so i tried something like this:
SUBSTRING(SI.Location, CHARINDEX('/', 2), 1) AS Testing
But this returns as blank so it doesn’t work. Any ideas how i can get this working?
SI is the name of the table and Location is the row.
Thanks
r937
2
try
SUBSTRING( SI.Location
, CHARINDEX('/',SI.Location,1)+1
, LEN(SI.Location) -
CHARINDEX('/',SI.Location,1)
) AS Testing
Thanks r937 that worked. I understand the CHARINDEX part where you are finding the index of where to start from.
Am i right in thinking that the LEN(SI.Location) - CHARINDEX(‘/’, SI.Location, 1) is checking for the slash and removing up to it?
Thanks again
r937
4
sort of, in a way… it’s actually just a length calculation
the “removal” is done by the SUBSTRING function