- 博客(37)
- 资源 (17)
- 收藏
- 关注
原创 了解筛选索引
博客园: http://www.cnblogs.com/wghao/archive/2013/05/09/3070032.html 开始筛选索引是SQL Server 2008中的一种新功能,它是对表中的部分行进行索引。基本语法:createnonclusteredindexindex_name on ob
2013-05-09 21:41:53 979
原创 解决SSIS的脚本任务编辑器加载超慢问题
原文:http://www.cnblogs.com/wghao/archive/2013/05/07/3065544.html 问题在使用SSIS (VS 2008 or VS 2012环境)中的脚本任务编辑器,当点击【编辑脚本】或【确认】位置时候,发现要等待很长一段时间,最糟糕的时候要等1分钟。如图1.
2013-05-07 21:06:58 1582
原创 SSIS学习视频(SQL Server 2008)
原文:http://www.cnblogs.com/wghao/archive/2013/05/06/3061984.html 这几天在找些有关SSIS的资料,在http://technet.microsoft.com上发现有SSIS方面的视频资料,感觉不错,对其进行整理,方便要学习SSIS的同学下载学习:编号视频内容视频简介
2013-05-06 08:06:54 3793
原创 2013年5月2日 用户自定义函数的数据库设计(DEMO)
开始以图1.来描述DEMO的需求:图1.在图1.设计一个DEMO系统能实现从【源数据】至【目标数据】的数据转换,转换过程能让用户通过调用自定义函数来实现。基本流程图 图2.图2.中的"多次调用"并表示多次调用同一个函数,而是可能存在先后调用不同的函数进行数据转换。函数f(
2013-05-02 08:20:58 789
原创 在SQL Server实现最短路径的搜索
排版完整的:http://www.cnblogs.com/wghao/archive/2013/04/23/3036965.html开始 这是去年的问题了,今天在整理邮件的时候才发现这个问题,感觉顶有意思的,特记录下来。在表RelationGraph中,有三个字段(ID,Node,RelatedNode),其中Node和Relat
2013-04-23 08:21:41 912
原创 在SQL Server中如何比较两个表的各组数据
开始 前一阵子,在项目中碰到这样一个SQL查询需求,有两个相同结构的表(table_left & table_right),如下:图1.检查表table_left的各组(groupId),是否在表table_right中存在有一组(groupId)数据(data)与它的数据(data)完全相等.如图1. 可以看出表table_left和table_right存在两组数据
2013-04-19 08:27:20 1486
原创 通过SQL绘制杨辉三角
无意中在csdn上看到一帖有关绘制杨辉三角的sql表达式,感觉很有意思。后来自己想下不借助临时表,根据杨辉三角的组合数计算方法C(n,m)=n!/[m!(n-m)!],进行绘制。以下是完整的SQL代码:use tempdbgoset nocount ondeclare @rows int=10, --行数,根据实际来控制 @x int=1,@y int=1,@sq
2013-04-11 08:07:04 922 1
原创 通用分页存储过程(SQL Server 2005)
这是不久前写的一个分页存储过程,可应用于SQL Server 2005上面: if object_ID('[proc_SelectForPager]') is not null Drop Procedure [proc_SelectForPager]GoCreate Proc proc_SelectForPager( @Sql varchar(max) , @Or
2013-01-23 15:46:30 777 1
原创 对存储过程进行加密和解密(SQL 2008/SQL 2012)
开始: 在网络上,看到有SQL Server 2000和SQL Server 2005 的存储过程加密和解密的方法,后来分析了其中的代码,发现它们的原理都是一样的。后来自己根据实际的应用环境,编写了两个存储过程,一个加密存储过程(sp_EncryptObject),和一个解密存储过程(sp_EncryptObject),它们可以应用于SQL Server中的储过程,函数,视图,以及触发器。
2012-12-30 17:16:45 1275
原创 重新组织和重新生成索引sp_RefreshIndex
开始: 在上周,客户反映一个系统问题,当处理大量数据的时候,出现网络超时。后来,我们跟踪测试,发现是由于索引碎片多而引起的网络超时。解决方法,自然是重新组织和重新生成索引。在这里,我写了一个存储过程sp_RefreshIndex来实现。 存储过程sp_RefreshIndex: use mastergoif object_id('sp_RefreshIn
2012-12-28 08:23:27 1064
原创 在外键上创建索引V1.0
开始: 发现在一个项目中,后台数据库各个表,具有外键约束的列上都没有创建索引。我们需要一次性给他们创建索引,下面我写了一个通用的存储过程sp_CreateIndexForFK,来实现这一个功能。也许有人问,为什么要在外键上创建索引,它有什么好处,可以参考:FOREIGN KEY 约束:http://msdn.microsoft.com/zh-cn/library/ms17546
2012-12-26 14:42:08 701
原创 刷新视图
问题: 当我们创建这样一个视图(myView):create view myView As select * from myTable 注:myTable的结构:myTable(id int)后来,我们改变了myTable的结构,增加一个字段(newCol):alter table myTable add newCol nvarchar(50)当
2012-12-26 14:40:37 818
原创 脚本文件比较工具WinMerge
在平时工作中,经常要比较不同版本的两个SQL脚本文件是否一致,后来找了一个比较工具WinMerge,感觉它不错,特拿来分享。图1.图1,是两个脚本文件的比较,左边的窗口显示个两个脚本文件,不同的位置,右边的主窗口,列出详细的差异位置,它能准确的标志处差异的行位置,及列位置。当然,可以对2个文件夹的脚本文件进行比较,如:当我们要查看两个文件不同的部分,只要双击对应的文件就
2012-12-20 10:08:01 1518
原创 微软的免费电子书
今早看到MSDN發了一微博,MSDN小編挖到一篇博客,作者搜集了大量来自微软的免费电子书,有Windows Phone, Windows 8, Visual Studio, Office 365等相关的书籍,海量免费正版电子书。感覺不錯,特分享給大家:http://blogs.msdn.com/b/mssmallbiz/archive/2012/07/27/large-collection
2012-12-17 11:46:01 658
原创 数据库性能优化--地址搜索
问题:有一张表TBAddress:字段名数据类型说明IDint主键Parentint父IDLevelNosmallint地址所在的层(范围:0 至 5)Namenvarchar(50)
2012-12-11 23:21:02 679
原创 修改表主键字段数据类型(up_ModifyPrimaryColumn)
开始:有一需求,就是把表中作为主键字段的数据类型从int 转换为 uniqueidentifier。我们可能会想到直接通过Microsoft SQL Server Management Studio (MSSMS)修改表结构,删除原来的主键,增加一个数据类型为uniqueidentifier的字段作为主键,并对它设置not null default(newid()) 。对于单独的表,主键没
2012-12-10 12:02:00 1842
原创 在SQL Server中查询Excel数据(sp_OpenExcel)
开始: 在工作中经常要把Excel的数据转换成SQL导入脚本,这里写了一个存储过程sp_OpenExcel,实现查询Excel文件并生成Insert脚本。sp_OpenExcel:Use masterGoif object_ID('[sp_OpenExcel]') is not null Drop Procedure [sp_OpenExcel]GoCr
2012-12-07 17:25:44 815
原创 生成创建表的脚本V2.0(PowerShell版)
之前寫有一篇有關《PowerShell应用之-生成创建表的Transact-SQL脚本》,今早再拿來應用的時候,發現無法按照指定的某一些表來生成腳本。現在特補充這一功能,先在原來腳本開頭位置,增加一個變量$TablesList: #===========================================#>##生成创建表的脚本V2.0,包含Constraint
2012-12-04 09:46:26 757
原创 一条Select语句导致瓶颈
情况:上周,公司一项目新上线,刚上线的第2天,在后台发现数据库服务器与IIS服务器的网络IO出现瓶颈,1GB的网络带宽,占用了70%-100%,也就是每秒传输数据700MB-1GB,数据库使用内存高达21GB。IIS服务器CPU使用率时常爆至80%-90%,导致网站频频出现连接超时。 原因:晚上只好暂时关闭网站,进行服务器维护,作全面的检查跟踪,发现是一句Select语句导
2012-05-12 13:34:35 847
原创 PowerShell应用之-事务复制
概述 在之前的几篇描述了PowerShell在SQL Server对SMO(SQL Server Management Objects)的管理,现在开始描述在SQL Server Replication中如何使用PowerShell脚本实现同步复制功能。在本篇中讲述的是实现同步复制中的事务复制,涉及如何创建Publishing,Distribution, Publication,
2011-11-22 23:52:21 905
原创 还原某一个目录下的所有数据库备份文件
引述在工作中,经常为测试或开发部门搭建数据库环境,每一次搭建环境,需要还原某一个目录下的所有数据库备份文件,也就是,一次需要还原一百多个数据库。每碰到类似的情况,需要编写一个SQL脚本来实现还原数据库的功能。这里就简单介绍如何编写存储过程来实现,还原某一个目录下的所有数据库备份文件。要实现还原某一个目录下的所有数据库备份文件,首先要实现还原某一个目录下的某一个备份文件。真实世界
2011-11-04 08:13:47 806
原创 合并SQL脚本文件
概述 在平时的工作中,我会经常的碰到这样需要合并SQL脚本的问题。如,有很多的SQL脚本文件,需要按照一定的先后顺序,再生成一个合并SQL脚本文件,然后再发布到用户SQL Server服务器上。 合并SQL脚本文件,最直接的方法就是新建1个空白的SQL脚本文件,再把需要合并的SQL脚本文件内容复制到新建的SQL文件中。当初,我合并脚本的操作方法与刚说的有类似。我在Micr
2011-11-04 08:12:35 775
原创 SQL Server 同步复制中的MSSQL_REPL-2147201001問題處理
引述 首先,说我为什么写这篇文章,它让你了解到什么,对你是否有帮助。要是你是刚接触SQL Server同步复制,那么你可能会碰到各种各样的问题,你可能不会从哪里入手解决,或者你从Baidu,Google上找到解决问题的方法,但你很多时候只看到别人说的答案,很少有人去写分析其中的原因,倘若你没有找其他资料或查阅帮助文档了解为什么,以后你碰到同样问题,你也只能照搬之前的答案,有时候碰巧正
2011-11-04 08:11:49 1455
原创 了解SQL Server触发器及触发器中的事务
引述 首先, 说下我写篇文章的目的,我希望能把我对触发器的理解,分享出来与你一起学习。如果你有对触发器和事务的概念,有些了解,这篇文章,对你来说会是很简单,或能让你更进一步的了解触发器里面的一些故事,和触发器中事务个故事。在这边文章里面,我不会从触发器和事务的概念去讲述,而是从常见的两种触发器类型(DML触发器 & DDL触发器)和After触发器 & Instead Of
2011-11-04 08:08:40 716
原创 可更新订阅的事务复制错误:列名 'msrepl_tran_version' 无效
问题描述: 首先,不知道你有没有类似的经历,在可更新订阅的事务复制,当初始化订阅时,发生了类似这样的错误:列名 'msrepl_tran_version' 无效 。(源: MSSQLSERVER,错误号: 207 ) 图1.通过复制监视器来检查错误 图2.通过作业的历史记录来检查错误 问题分析: 我们知道,在
2011-11-04 08:07:44 1289
原创 在运行SSIS包时,如何动态更新变量值
实现方式: 若要动态更新变量,可以为变量创建配置,将这些配置部署到包中,然后在部署包时更新配置文件中的变量值。这样,在运行时,包就可以使用更新后的变量值。 下面通过一个简单的例子来说明如何实现动态更新变量值。例子要求: 把一张Order表从远程计算机实例“TRIY-2FE792BB5D\SQL2008DE” 根据需要输入(Order.dbo
2011-11-04 08:06:37 2299
28岁学习Java笔记(1)--准备
一、为什么要学习Java 学习Java,是为了实现过来的梦想。追溯到大学里的2003年,那时候我们学习编程的教材是有关passcal & Turbo C,可选编程语言有VB,C++,Delphi,PHP,当时我选择了VB,因为它简单容易入手(因为选择它,后来的几年的工作也是做有关VB程序开发)。记得有一次,来自澳洲的一位教授来给我们讲座,谈了国外的Java,甲...
2010-04-24 00:51:23 332
28岁学习Java
一直以来学习Java是我的梦想,可惜我今年28岁了,之前之所以没有实现梦想,我暂且不说,因为那已经成为过去了,我现在开始学习Java.我凭着一个要实现学习Java的梦想,去开始学习它。我希望今天这一个起点,能改变我以后的路程。这里将记录了我全程的学习过程! :arrow: ...
2010-04-22 07:12:34 577
原创 生成CURD脚本的存储过程
CRUD 定义了用于处理数据的基本原子操作。 它代表创建(Create)、读取(Read)更新(Update)和删除(Delete)操作。 下面的脚本可以实现简单的curd功能。编写存储过程主要考虑问题:第一个字段不一定是主键主键不一定只对应一个字段。有字段具有Identity属性的时候,需要返回最后的标准值。生成的Curd 代码格式要整齐好看。
2009-04-07 22:28:00 978
原创 模仿sp_executesql,制作一个自己的executesql脚本
参照sp_executesql 的使用语法格式是:sp_executesql [ @stmt = ] stmt[ {, [@params=] N@parameter_name data_type [ OUT | OUTPUT ][,...n] } {, [ @param1 = ] value1 [ ,...n ] }]参考其中的一些
2008-06-12 23:00:00 1373 1
原创 X进制与10进制之间的转换
Declare @x nvarchar(1024) Declare @y int Declare @sys int --x进制 Set @x=30 Set @sys=21 --@sys=21表示二十一进制 --x进制转换成10进制 ;With T1 As( Select X=Stuff(Revers
2008-06-12 01:21:00 1397
原创 自动生成Insert数据的SQL脚本
判断当表存在标识列的时候就要允许将显式值插入表的标识列中,设置:Set Identity_Insert TableName Off 判断数据类型如,varchar,char,datetime,nvarchar,nchar,uniqueidentifier时候,在Insert字段中就要增加双引号,否则就不加; Code highlighting produced by Actipro C
2008-06-08 18:14:00 1615
原创 从Windows转到Linux/Unix
使用微软的产品已有多年,总感觉微软的产品更新太快.让有人一种疲惫不堪的感觉,一不小心就给淘汰。现在下决心从Windows转向Linux/Unix,从MS SQL转向Oracle,从DOTNET转向JAVA。可能很多人说我的选择是错误的,也可能有些人说是正确的。不管怎么样为了一直走IT这路子,决心已定,相信自己的选择是对的。
2007-09-03 10:35:00 1229
原创 索引的使用说明
索引的使用说明题外话: 昨天比较郁闷,维护一客户的数据库系统时候,发现系统处理数据就出现假死。开始因为是软件问题,拷得乱忙一下午还没有拷定,后来一直弄到晚上7点,突然想起索引问题。后来就使用了一命令:dbcc dbreindex(TableName,,80)即可实现。比较郁闷和晕,自己犯这样的错误。 这错误,正好是我想写这帖的原因,希望能为大家解
2007-07-06 16:50:00 1947
原创 SQL 绘画日历
今日周末没事就这脚本玩玩 脚本: /*功能:绘画日历设计:OK_008时间:2006-05*/DECLARE @Year nvarchar(4)DECLARE @YearMonth nvarchar(7) --月份DECLARE @strTop nvarchar(200)DECLARE @ForI INT,@
2006-05-13 19:40:00 1591
原创 SQL中,怎么样自动生成表的更新脚本
上次在csdn,这里写了这问题,一直没人帮忙解。苦等不如,自己想办法。 原问题是: 每当新建一个数据表,要建立个UP_TableName的存储过程来实现表的INSERT UPDATE DELETE操作。 如建立了个表是 WoolenDeliveDetail,更新表的存储过程是UP_
2006-05-12 19:50:00 2223
原创 C#.net多线程的学习 (自学篇)
.net框架的System.Threading命名空间提供了一些可以进行多线程编程的类和接口。除同步线程活动和访问数据的类(Mutex、Monitor、Interlocked、AutoResetEvent 等)外,此命名空间还包含一个 ThreadPool 类(它允许用户使用系统提供的线程池)和一个 Timer 类(它在线程池线程上执行回调方法)。 以Thread类来说明,在MSDN
2006-05-12 08:22:00 2799
CodeSmith Generator 7.0.2.15174 (含注册机)
2015-06-13
Physical Database Design (2007)
2013-07-26
Manning.Windows.PowerShell.in.Action
2013-06-26
WPF编程%28第二版%29中文版00008
2013-06-23
SQL_Server_2000_2005_2008_2008_R2查询智能分析器RedGate_SQL_Prompt_V5.3.4.1
2013-05-03
MySQL技术内幕(第4版).pdf
2013-01-15
Programming+Python,+4th+Edition(2/2)
2011-05-29
Programming+Python,+4th+Edition(1/2)
2011-05-29
iBatis in action (PDF)
2010-01-28
SQLServer2000常用函数大全及个人收藏
2007-04-30
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人