Solved

PATINDEX/REVERSE

Posted on 2007-04-02
2
2,139 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

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…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

756 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