問題:我想每日從數(shù)據(jù)庫里導(dǎo)出一些數(shù)據(jù),內(nèi)容基本上都是一樣的,只是時(shí)間不同,比如導(dǎo)出一張表wjz
create table wjz
(id int,
name varchar(10),
create_time datetime)
每天要導(dǎo)出的內(nèi)容為select * from wjz where create_time >convert(varchar(30),getdate()-1,112) and create_time < convert(varchar(30),getdate(),112)
然后生成的文本文件名為 wjz_yyyymmdd.txt
關(guān)鍵是這個(gè)文件名怎么實(shí)現(xiàn)?
解決方法:
修改文件連接器的表達(dá)式,可以設(shè)置成:
@[用戶::FileDir]+" wjz_"+ (DT_WSTR, 4) YEAR( GETDATE() ) + (DT_WSTR, 2) MONTH( GETDATE() ) + (DT_WSTR, 2) DAY( GETDATE() ) +".txt"
create table wjz
(id int,
name varchar(10),
create_time datetime)
每天要導(dǎo)出的內(nèi)容為select * from wjz where create_time >convert(varchar(30),getdate()-1,112) and create_time < convert(varchar(30),getdate(),112)
然后生成的文本文件名為 wjz_yyyymmdd.txt
關(guān)鍵是這個(gè)文件名怎么實(shí)現(xiàn)?
解決方法:
修改文件連接器的表達(dá)式,可以設(shè)置成:
@[用戶::FileDir]+" wjz_"+ (DT_WSTR, 4) YEAR( GETDATE() ) + (DT_WSTR, 2) MONTH( GETDATE() ) + (DT_WSTR, 2) DAY( GETDATE() ) +".txt"