2013-10-15 2 views
0

이 코드를 사용하여 bak 파일 이름을 얻을 때 #tmpTable 마지막 행이 null 인 이유는 무엇입니까?왜 #tmpTable 마지막 행이 null입니까?

--Configure extension procedure the cmd_shell enable 
     declare @backupfile_store_path varchar(200) 
       ,@DynamicSql varchar(200) 
     exec sp_configure 'show advanced options',1; 
     reconfigure; 
     exec sp_configure 'xp_cmdshell',1; 
     reconfigure; 
     if (OBJECT_ID('tempdb.dbo.#tmpTable') is not null) 
     drop table #tmpTable --#tmpTable 
     --select OBJECT_ID('tempdb.dbo.#tmpTable') 

    create table #tmpTable 
    (
     DBName varchar(200) 
    )  
    set @backupfile_store_path='E:\20131015' 
    /*using extended procedure xp_cmdshell to get the path and name*/ 
    set @DynamicSql='cd /d "'[email protected]_store_path+'"&&dir /a /b /s *.bak' 
    insert into #tmpTable exec xp_cmdshell @DynamicSql 
    select * from #tmpTable 

내가이 명령을 사용하는 경우 :

C:\Users\Administrator>cd /d e:\20131015 

e:\20131015>dir /a /b /s *.bak>>c:\a.txt 

e:\20131015> 

txt 파일의 마지막 행이 빈 열이 왜 빈 열이 있습니다?

+1

와우, 여기에 몇 가지 속임수가 있습니다. 너의 dir과 쉘 명령이 돌려주는 것을 잘 보아라. –

답변

0

윈도우 약 dir 명령과 마지막 출력은 빈 줄입니다.