易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL 中将一个表转化成建表语句的存储过程

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE proc pGetInsertSQL (@TableName varchar(256))
as
begin
    set nocount on
    declare @sqlstr varchar(4000)
    declare @sqlstr1 varchar(4000)
    declare @sqlstr2 varchar(4000)
    select @sqlstr='select ''insert '+@tablename
    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+','''


相关文档:

常用的ORACLE PL/SQL管理命令一

原文:刘武| 常用的ORACLE PL/SQL管理命令一
熟悉ORACLE管理的一定对这些命令不会陌生,不过对于我这个刚接触ORACLE管理的来说,还是有必要做下记录,以便随时查看。
一 登录SQLPLUS
sqlplus 用户名/密码@数据库实例 as 登录角色;
如:用户sys(密码为123)以sysdba的角色登录数据库ORACL,我们可以输入:sqlplus sy ......

SQL中没用集合的minus,用union实现

列出TableA中有的而TableB中没有, 以及B中有而A中没有的记录:
其中两个表的结构相同,选择的Key可以多个
Select Key from
( select * from TableA
Union select * from TableB
)
group by Key
having count(Key)=1

列出TableA中有的而TableB中没有的记录:
Select Key from
( (select * from TableA
Un ......

Sql 2000 数据库备份实例

数据库备份实例/**
**数据库备份实例
**朱二 2004年5月
**备份策略:
**数据库名:test
**备份文件的路径e:\backup
**每个星期天凌晨1点做一次完全备份,为保险起见,备份到两个同样的完全备份文件test_full_A.bak和test_full_B.bak
**每天1点(除了星期天)做一次差异备份,分别备份到两个文件test_df_A.bak和test_df ......

mysql导入sql文件:Mysql导入导出.sql文件

mysql导入sql文件:Mysql导入导出.sql文件
步骤如下:
一.MYSQL的命令行模式的设置:
桌面->我的电脑->属性->环境变量->新建->
PATH=“;path\mysql\bin;”其中path为MYSQL的安装路径。
二.简单的介绍一下命令行进入MYSQL的方法:
1.C:\>mysql -h hostname -u username -p
按ENTER ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号