DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Find Exact Directory Name Of Variable Directory Name
This sql server procedure help you, if you have remmember some string of your directory and path name then you will get the exact directory name of that path.
create proc usp_srchDir ( @pathName nvarchar(100), @strDirName nvarchar(50), @ExactName nvarchar(20) OUTPUT ) AS BEGIN SET NOCOUNT ON DECLARE @strCMD nvarchar(500) SET @strCMD='dir "'+ @pathName +'" /ad/o | find /I "'+@strDirName+'"' create table tblFindDIR(SearchDIRName nvarchar(200)) insert into tblFindDIR(SearchDIRName) exec master.dbo.xp_cmdshell @strCMD delete from tblFindDIR where isnull(SearchDIRName,'')='' select @ExactName=ltrim(rtrim(right(SearchDIRName,20))) from tblFindDIR where SearchDIRName like '%'+@strDirName+'%' drop table tblFindDIR SET NOCOUNT OFF END GO





