Exec master.dbo.xp_cmdshell
'bcp "select * from db.dbo.tb where datediff(dd,getdate(),col)= -1"
queryout "这里怎么写??" -c '我想把文件名写成 vis070108.txt这样 或者其他的日期格式也可以 主要是有有个前一天日期在文件名里面
'bcp "select * from db.dbo.tb where datediff(dd,getdate(),col)= -1"
queryout "这里怎么写??" -c '我想把文件名写成 vis070108.txt这样 或者其他的日期格式也可以 主要是有有个前一天日期在文件名里面
declare @t varchar(8)
set @t = convert(varchar(8),getdate(),112)
exec('exec master..xp_cmdshell ''bcp "select * from db.dbo.tb where datediff(dd,getdate(),col)= -1" queryout "e:\vis'+@dt+'" -c ''')bcp语句没写完,你自己根据需要补上
还有其他的方法可以实现 导出数据成TXT文件 文件名 按日期吗?
if not exists (select * from dbo.sysobjects where id=object_id(N'[dbo].xp_cmdshell]') and OBJECTPROPERTY(id,N'IsExtendedProc')=1)
exec sp_addextendedproc xp_cmdshell,@dllname='xplog70.dll'