30天以内:select count(*) from TB where datediff(day,字段名,getdate()) between 0 and 3030-60天:select count(*) from TB where datediff(day,字段名,getdate()) between 30 and 6060-90天:select count(*) from TB where datediff(day,字段名,getdate()) between 60 and 9090天以外:…
我们有时候会需要查询数据库中包含某字段的所有的表,去进行update,这时就可以用下面的SQL来实现: select object_name(id) objName,Name as colName from syscolumns where (name like'%此次写需要查询的字段名称%')and id in(select id from sysobjects where xtype='u')order by objname; 当然也可以使用游标,把查询出来的Table串接起来,如下: DE…
测试在项目中是很重要的一个环节,在Visual Studio 2010中,在测试方面已经有很好的支持了,比如有单元测试,负载测试等等.在数据测试的方面,Visual Studio 2010,还支持对数据库进行多种测试,其中一个很好用的功能是能为开发者在测试阶段,大量方便地为数据库生成随机的数据,而且还可以自己指定生成数据的规则,十分方便,这就让在测试过程中,开发者能有更充足的数据样本对项目进行测试.本文则介绍其中的Data Generation数据生成器的使用方法. 1 创建SQL Server…