--导出数据
declare @sql varchar(8000)
set @sql='bcp "select * from(select null as 类型 union all select 0 as 前缀 union all select 0 as 长度 union all select null as 结束 union all select null as 格式) a" queryout "'
+@tmpfn+'" /c /S"zj" /P""'
exec master..xp_cmdshell @sql,no_output
set @sql='bcp ##tb out "'+@fn+'" /S"zj" /P"" /i"'+@tmpfn+'"'
exec master..xp_cmdshell @sql,no_output
set @sql='del '+@tmpfn
exec master..xp_cmdshell @sql,no_output
go
drop table ##tb