Solved

PATINDEX/REVERSE

Posted on 2007-04-02
2
2,161 Views
Last Modified: 2012-06-21
sql 2k5. I am using this to view a network path as a filename only. the problem is that some of the records have no path, but 'N/A'. For those records I am getting an error. select statement and error shown below.

adria
*************************************************************
Select Statement:
*************************************************************
use [spindle test]
go
select (right(imagepath_1,
      PATINDEX('%\%', REVERSE(imagepath_1))-1)) as Filename_1
from tblTD_Pics

*************************************************************
Error:
*************************************************************
Msg 536, Level 16, State 2, Line 1
Invalid length parameter passed to the RIGHT function.
0
Comment
Question by:adraughn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18839884
select case when imagepath_1 like '%\%' then  (right(imagepath_1,
      PATINDEX('%\%', REVERSE(imagepath_1))-1)) else imagepath_1 end as Filename_1
from tblTD_Pics
0
 
LVL 13

Author Comment

by:adraughn
ID: 18839905
thanks angel. now i can go home...

adria
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question