Solved

PATINDEX/REVERSE

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query 2 63
Testing connection to sql 7 61
Upgrading SQL 2005 Express to 2008 R2 Express 31 127
Please help for the below sql query. 1 28
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In this article I will describe the Backup & Restore 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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

840 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