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)
 get just filename

Author  Topic 

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-05-23 : 07:06:57
If you use "SELECT filename FROM sys.sysdatabases" this will return
the full path , such as "E:\MSSQL\data\myData.MDF" ,

is it possible to return just the "myData.MDF" part of it?
I know that you can parse the string , but is it stored somewhere else , or is there a command that will return just the physical file name ?

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-23 : 07:11:49
[code]SELECT dbid,
name,
RIGHT(filename, CHARINDEX('\', REVERSE(filename)) - 1)
FROM sys.sysdatabases[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -