0
當我使用此代碼獲取bak文件名時,爲什麼#tmpTable
最後一行是空?爲什麼#tmpTable最後一行是空的?
--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文件的最後一行有一個空白列,爲什麼它有一個空白列?
哇,這是在這裏進行一些欺騙。那麼看看你的dir和shell命令返回什麼 –