SQL SERVER 查詢目標資料夾下的所有檔案

2021-06-08 05:34:42 字數 1455 閱讀 1786

use 

go/****** object: storedprocedure [dbo].[dbtools_sys_directorygetlist] script date: 2012/8/2 11:24:52 ******/

set ansi_nulls on

goset quoted_identifier on

go/*------------------------------------

-- 用途: 列出目標資料夾下的所有檔案

-- 專案名稱:

-- 說明:

-- 編寫者:

--------------------------------------

-- 修改記錄:

-- 編號 修改時間 修改人 修改原因 修改標註

------------------------------------*/

/* 測試語句

declare @r int

exec @r=dbtools_sys_directorygetlist ''

select @r

*/create procedure [dbo].[dbtools_sys_directorygetlist]

( @dir nvarchar(128)

) as

begin

set nocount on

declare @sql nvarchar(max),@return int=0

create table #temp (recno int identity,output nvarchar(100))

set @sql=n'exec sp_configure ''show advanced options'',1

reconfigure with override;

exec sp_configure ''xp_cmdshell'',1

reconfigure with override;

insert into #temp(output)

exec xp_cmdshell ''dir '+@dir+'\*.bak'' --呼叫dos命令列出資料夾;

exec sp_configure ''xp_cmdshell'', 0

reconfigure with override;

exec sys.sp_configure n''show advanced options'', n''0''

reconfigure with override;

'--print @sql

exec(@sql)

select right(output,charindex(' ',reverse(output))-1)

from #temp

where output like '%.bak'

end

在Sql Server中查詢Excel檔案資料

在sql server中查詢excel檔案資料 執行語句 select from opendatasource microsoft.jet.oledb.4.0 data source c book1.xls user id admin password extended properties exc...

目標檔案裡有什麼 揭秘目標檔案

程式源 被編譯後生成的機器指令被放在 段 text 全域性變數和區域性靜態變數被放在資料段 data 除此之外還有程式裡邊的唯讀變數 如const修飾的變數 和字串常量被分配在唯讀資料段 rodata 注釋資訊段 comment 堆疊提示段 nute.gnu stack 未初始化的全域性變數和靜態區...

SQL Server 分頁查詢

ps,此文是純個人筆記 公司裡乙個專案裡用到了一種資料庫分頁查詢的方式 1 定義乙個臨時的table 這個table有乙個自增的之間id,和要查的資料表的主鍵id 2 再一次查詢,用id在分頁數段來and 一下結果 具體操作如下 定義個臨時表 temptable declare temptable ...