易截截图软件、单文件、免安装、纯绿色、仅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(


相关文档:

SQL Server CE服务器端和客户端安装配置学习笔记

 
SQL Server 2005 CE开发环境介绍:
       最近学习使用SQL Server 2005 Compact Edition进行数据存储,在学习的过程中发现,使用SQL Server2005 management Studio创建数据库时,在“服务器类型”下拉列表中没有“SQL Server Compact Edition”选项。因为文章 ......

sql调优之 寻找我们最感兴趣的语句

Tuning an Application / Reducing Load
If your whole application is performing suboptimally, or if you are attempting to
reduce the overall CPU or I/O load on the database server, then identifying
resource-intensive SQL involves the following steps:
1. Determine which period in the day you would ......

sa登陆失败 SQL Server错误18456的解决方法

昨天我的SQL(Microsoft SQL Server 2005 )登录不上去了,原来是出现了几个小问题,现在记录一下我的解决这几个情况的办法。(解决方法有很多种,这些只是我的解决方法,仅供参考)
查找问题的过程:(注:用windows账号还是可以登录的)
第一步:启动所有与SQL有关的服务,问题依旧;
第二步:查看windows防火墙,被默 ......

SQL Group By Top 实现

DECLARE @temp TABLE(
id INT,
[name] VARCHAR(50),
class VARCHAR(50)
)
INSERT INTO @temp
SELECT 1,'a','A'
UNION ALL SELECT 2,'b','C'
UNION ALL SELECT 3,'c','B'
UNION ALL SELECT 4,'d','C'
UNION ALL SELECT 5,'e','B'
UNION ALL SELECT 6,'f','A'
SELECT * from @temp AS _temp WHERE [name] IN
( ......

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号