create proc proc_insert (@tablename varchar(256))
as
begin
set nocount on
declare @sqlstr varchar(4000)
declare @sqlstr1 varchar(4000)
declare @sqlstr2 varchar(4000)
select @sqlstr='select ''insert
select @sqlstr1=''
select @sqlstr2=' ('
select @sqlstr1= ' values ( ''+'
select @sqlstr1=@sqlstr1+col+'+'',''+' ,@sqlstr2=@sqlstr2+name +',' from (select case
-- when a.xtype =173 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.length*2+2)+'),'+a.name +')'+' end'
when a.xtype =104 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(1),'+a.name +')'+' end'
when a.xtype =175 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'
when a.xtype =61 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +',121)'+ '+'''''''''+' end'
when a.xtype =106 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.xprec+2)+'),'+a.name +')'+' end'
when a.xtype =62 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(23),'+a.name +',2)'+' end'
when a.xtype =56 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(11),'+a.name +')'+' end'
when a.xtype =60 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(22),'+a.name +')'+' end'
when a.xtype =239 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'
when a.xtype =108 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.xprec+2)+'),'+a.name +')'+' end'
when a.xtype =231 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'
when a.xtype =59 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(23),'+a.name +',2)'+' end'
when a.xtype =58 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +
导出sql语句
来源:这里教程网
时间:2026-02-28 05:57:20
作者:
编辑推荐:
- sql常用函数02-28
- 导出sql语句02-28
- sql server replace 批量替换数据库中指定字段内容02-28
- sqlserver 数据库被注入解有效处理方法02-28
- sql如何去除重复数据02-28
- SQL2005 高效分页sql查询语句经典实例02-28
- 如何修改SQL Server 2005/2008 数据库路径02-28
- mssql 存储过程入门与实例应用02-28
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 新手必备,教你轻松安装Win10系统!
新手必备,教你轻松安装Win10系统!
26-02-28 - Windows开机黑屏如何重装系统?【图文详解】
Windows开机黑屏如何重装系统?【图文详解】
26-02-28 - 云计算之路-阿里云上:超级奇怪的“黑色10秒钟”
云计算之路-阿里云上:超级奇怪的“黑色10秒钟”
26-02-28 - 解决SYS本地登录或远程登录引起ORA-01031错误方法
解决SYS本地登录或远程登录引起ORA-01031错误方法
26-02-28 - ora-12154:tns:无法解析指定的连接标识符
ora-12154:tns:无法解析指定的连接标识符
26-02-28 - 创建 Oracle 分页存储过程
创建 Oracle 分页存储过程
26-02-28 - NoSQL学习之路(四):创建、读
NoSQL学习之路(四):创建、读
26-02-28 - ORALCE 查询当前月的所有日期sql语句
ORALCE 查询当前月的所有日期sql语句
26-02-28 - oracle中创建数据表入门篇
oracle中创建数据表入门篇
26-02-28 - 联想笔记本免费升级到Win11最新系统的教程
联想笔记本免费升级到Win11最新系统的教程
26-02-28
