Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to check the string backslash in the path

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2009-11-30 : 13:39:37
How to check if there is a backslash"|" at the end of the path or not:

SET @filepath = "D:\AllFiles\MYProjects\CIP\3002A-07\D001\"

if @filepath has a backslash"\" at its end on the right, then set @filepath='' otherwise ignore.

sometimes this path is appearing with a filename at the end.

Thank you very much.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-30 : 13:41:37
Here's what I use to ensure there is always a backslash at the end:

IF RIGHT(@path, 1) <> '\'
SET @path = @path + '\'


Modify it to suit your needs.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-30 : 13:43:02
where right(@filepath,1)='\'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-30 : 13:44:12

sniped by the Goddess...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-01 : 01:59:44
or

if @filepath like '%\'
--do stuff

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -