(MS SQL Server)SQL语句导入导出大全(8)
发布时间:2021-06-06
发布时间:2021-06-06
if @fsize is null
begin
print ’文件未找到’
return
end
end
--生成数据处理应答文件
set @m_tbname=’[##temp’+cast(newid() as varchar(40))+’]’ set @sql=’select * into ’+@m_tbname+’ from(
select null as 类型
union all select 0 as 前缀
union all select ’+@fsize+’ as 长度
union all select null as 结束
union all select null as 格式
) a’
exec(@sql)
select @fname_in=@fname+’_temp’
,@sql=’bcp "’+@m_tbname+’" out "’+@fname_in
+’" /S"’+@servename
+case when isnull(@username,’’)=’’ then ’’
else ’" /U"’+@username end
+’" /P"’+isnull(@password,’’)+’" /c’
exec master..xp_cmdshell @sql
--删除临时表
set @sql=’drop table ’+@m_tbname
exec(@sql)
if @isout=1
begin
set @sql=’bcp "select top 1 ’+@fdname+’ from ’
+@tbname+case isnull(@tj,’’) when ’’ then ’’
else ’ where ’+@tj end
+’" queryout "’+@fname
+’" /S"’+@servename
+case when isnull(@username,’’)=’’ then ’’
else ’" /U"’+@username end
+’" /P"’+isnull(@password,’’)
+’" /i"’+@fname_in+’"’
exec master..xp_cmdshell @sql
end
else
begin
--为数据导入准备临时表
set @sql=’select top 0 ’+@fdname+’ into ’
上一篇:2014广东省高考压轴卷 文科数学 Word版含解析
下一篇:抵押合同(公司)