27,579
社区成员
发帖
与我相关
我的任务
分享
if OBJECT_ID('temtable','u')is not null
drop table temtable
select * into temtable from (select 'team_id'as [teamid],'team_name' as [team_name]
union all
select [team_id], [team_name] from team)a
declare @filename nvarchar(30)
select @filename='d:\'+ convert(char(8),getdate(),112)+'.xls'
declare @strSQL nvarchar(1024)
select @strsql='bcp "select team_id,team_name from pj131402..temtable" queryout "' + @filename + '" -c -q -S"yhm" -U"sa" -P"test"'
print @strSQL
EXEC master..xp_cmdshell @strSQL
declare @filename char(15),@sql varchar(4000)
select @filename='c:\'+ convert(char(8),getdate(),112)+'.xls'
select @sql='bcp "select ''编号'' 编号 union all select rtrim(编号) from pj131402..Teacher_new" queryout "' + @filename + '" -c -q -S"yhm" -U"sa" -P"test" '
exec master..xp_cmdshell @sql
if OBJECT_ID('temtable','u')is not null
drop table temtable
select * into temtable from (select 'applicationID'as [applicationID],'Category' as [Category]
union all
select CONVERT(varchar(20),[applicationID]), [Category] from #temtable)a
declare @filename nvarchar(30)
select @filename='Report'+right(replace(convert(date,GETDATE()),'-',''),2)+substring(replace(convert(date,GETDATE()),'-',''),5,2)+substring(replace(convert(date,GETDATE()),'-',''),1,4)+'.csv'
------------------------------------------
declare @strSQL nvarchar(1024)
set @strSQL='bcp "SELECT applicationID,Category FROM db.dbo.tb" queryout C:\Temp\DBA_date\'+@filename+' -c -T -t","'
print @strSQL
EXEC master..xp_cmdshell @strSQL
declare @filename nvarchar(30)
select @filename='Report'+right(replace(convert(date,GETDATE()),'-',''),2)+substring(replace(convert(date,GETDATE()),'-',''),5,2)+substring(replace(convert(date,GETDATE()),'-',''),1,4)+'.csv'
------------------------------------------
declare @strSQL nvarchar(1024)
set @strSQL='bcp "SELECT applicationID,Category FROM db.dbo.tablename" queryout C:\Temp\DBA_date\'+@filename+' -c -T -t","'
print @strSQL
EXEC master..xp_cmdshell @strSQL
--create qurey result
--sp_configure 'show advance',1
--go
--reconfigure
--go
--sp_configure 'xp_cmdshell',1
--go
--reconfigure
--go