Solved

PATINDEX/REVERSE

Posted on 2007-04-02
2
2,064 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
2 Comments
 
LVL 142

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
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…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now