摘要: Generating Random Numbers in Transact-SQLThe Transact SQLRandfunction can be used to return a random floating point number between 0 and 1:SELECT RAND() AS RandomNumberThe Rand function can also be supplied with an integer value (i.e. smallint, tinyint or int) to use as a random seed:SELECT RAND(@My 阅读全文
posted @ 2012-03-01 17:36 programming snail 阅读(1309) 评论(1) 推荐(0) 编辑
摘要: An indexed view serves a different purpose than a table. Also - if there is no table, then there can be no view.A table is for storing actual data.A view can be used for presenting data from tables in a user-friendly manner, for instance by replacing foreign key values that are substitute keys, wit. 阅读全文
posted @ 2011-03-17 12:46 programming snail 阅读(230) 评论(0) 推荐(0) 编辑
摘要: SQL Server 2000 and 2005 both use a "cost-based" optimizer to quickly locate data in its databases.Indexes are actually internal tables, and work like the index in a book – it contains a list of... 阅读全文
posted @ 2010-05-13 11:53 programming snail 阅读(369) 评论(0) 推荐(0) 编辑
摘要: ne of the most important knobs and levers you have in tuning a system from the database perspective is in your database'sindexes. The indexes you apply (or don’t apply) can create performance ga... 阅读全文
posted @ 2010-05-13 11:41 programming snail 阅读(220) 评论(0) 推荐(0) 编辑
摘要: ore than any other tuning you can perform; creating efficient queries will always give you the most return for your time and effort. I've managed to squeeze a few more percentage points of performance... 阅读全文
posted @ 2010-05-13 11:33 programming snail 阅读(403) 评论(0) 推荐(0) 编辑
摘要: create table #t(name varchar(255), rows bigint, reserved varchar(20), data varchar(20), index_size varchar(20), unused varchar(20))exec sp_MSforeachtable "insert into #t exec sp_spaceused '?'"select *... 阅读全文
posted @ 2010-05-10 11:41 programming snail 阅读(427) 评论(0) 推荐(0) 编辑
摘要: 这是一个在我实际一个项目中遇到的问题。03BHL01001(上海)和03BHL01001(上海)比较的结果是一样的。导致引起的重复的主键问题。  03BHL01001(上海)和03BHL01001(上海)差别,就在于前者的括号是全角的括号字符,后者是半角的括号字符。全角的括号字符和半角的括号字符的ascii码显然是不一样的。全角的( ASCII码是0xA3A8 ,而半角的( 是0x28。那么为什么... 阅读全文
posted @ 2010-04-22 17:28 programming snail 阅读(690) 评论(1) 推荐(0) 编辑
摘要: 可伸缩性性是数据库管理系统的一个很重要的方面,在SQL Server 2005中可伸缩性方面提供了表分区功能。其实对于有关系弄数据库产品来说,对表、数据库和服务器进行数据分区的从而提供大数据量的支持并不是什么新鲜事,但 SQL Server 2005 提供了一个新的体系结构功能,用于对数据库中的文件组进行表分区。水平分区可根据分区架构,将一个表划分为几个较小的分组。表分区功能是针对超大型数据库(从... 阅读全文
posted @ 2010-01-06 11:59 programming snail 阅读(345) 评论(0) 推荐(0) 编辑
摘要: SQL Server通过锁定资源来保证数据库的一致性。SQL Server中的锁不会对行、页、表或索引等资源有实际影响,它更像一个预订系统,所有任务在数据库内预订某些资源时都遵守它。过多的锁或长时间持有的锁会导致阻塞和其他问题,但锁本身也可能产生一些问题。1 解决锁内存问题为了确定SQL Server中锁使用的内存量,可以监视SQL Server中的“锁内存(KB)”计数器... 阅读全文
posted @ 2009-11-25 09:22 programming snail 阅读(1191) 评论(2) 推荐(0) 编辑
摘要: SQL Server 2005 的分区表(partition table)是复杂的,特别是对于初学者来说。不管怎样,我们还是掌握了分区函数(partition function),分区方案(partition scheme),最后终于创建了一个分区表出来。但之后呢,或许你想查看分区表的各个分区分区列的取值范围(这个分区的理论最小值和最大值),虽然可以通过分区函数中定义的边界值(boundary... 阅读全文
posted @ 2009-10-21 18:18 programming snail 阅读(597) 评论(0) 推荐(0) 编辑