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

存储过程, 生成SQL语句

USE [sfaecrm]
GO
/****** 对象:  StoredProcedure [dbo].[proc_insert]    脚本日期: 05/29/2009 06:16:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[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 '+@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 =127 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(20),'+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(


相关文档:

Asp.Net中sql server 2000/2005 连接字符串


http://zhanglei1286.blog.163.com/blog/static/1895797120091112113019600/
在后台代码里:
SQL 2000:
static string StrConn = "server=.;uid=sa;pwd=sa;database=MyCUDS";
SQL2005:
con = new SqlConnection(@"Server=.\SQLExpress;Database=db_CMS;Persist Security Info=True;User ID=sa;Password=Masslong"); ......

用TSQL把Access的表导入到远程Sql Server

用TSQL把Access的表导入到远程Sql Server:
把access 的.mdb里t_itemList 表的数据插入到远程SqlServer的t_itemL1111111表里。
SELECT  top 10 *  INTO  t_itemL1111111 IN [ODBC] 
[ODBC;Driver=SQL Server; UID=jyb;PWD=jyb;Server=10.1.18.49;DataBase=所有合并;]
    &nb ......

SQL命令大全 中英文对照

[code=SQL][/code]
--语 句 功 能 
--数据操作 
SELECT --从数据库表中检索数据行和列 
INSERT --向数据库表添加新数据行 
DELETE --从数据库表中删除数据行 
UPDATE --更新数据库表中的数据 
--数据定义 
CREATE TABLE --创建一个数据库表 
DROP TABLE --从数据 ......

SQl Cookbook学习笔记

1.select  * from A where a.a='a';
  执行顺序 先执行 from 在执行 where 中的东西 ,最后执行 select
2.列值连接 db2 oracle ||  , mysql concat(column1,'sss',column2) sqlServler使用+连接;
3. case when  表达式 then ''
           ......

sql语句优化原则

1.多where,少having
where用来过滤行,having用来过滤组
2.多union all,少union
union删除了重复的行,因此花费了一些时间
3.多Exists,少in
Exists只检查存在性,性能比in强很多,有些朋友不会用Exists,就举个例子
例,想要得到有电话号码的人的基本信息,table2有冗余信息
select * from table1;--(id,n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号