Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am saving some uploaded file name in database.. its saving with the file extension.. and some only with document name.

So while retrieving the records i want to check if any extension like (.docx)etc is existing in the value, check and remove the value in stored procedure itself.


Is there any way in Sql Server 2008


Thank you,
yashoda
Posted

1 solution

Give this a go, replace [Path] with the name of your field and [Files] with the name of your table

SQL
SELECT
    CASE WHEN CHARINDEX('.',REVERSE([Path])) > 1 THEN LEFT([Path], LEN([Path]) - CHARINDEX('.',REVERSE([Path]))) ELSE [Path] END AS FileNameWithoutExtension
FROM
    [Files]
 
Share this answer
 
Comments
bandayashoda 11-Mar-11 5:10am    
The solution given is working..... Thank you
Dylan Morley 11-Mar-11 5:11am    
OK - mark solution as answer then please so people know this question is closed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900