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
You need to create an account or log in to post comments to this site.