技巧 These has been picked up from thread within sqljunkies Forums http://www.sqljunkies.com ProblemThe problem is that I need to round differently (by halves) Example: 4.24 rounds to 4.00, but 4.26 rounds to 4.50. 4.74 rounds to 4.50 and 4.76 rounds t
--1.不要使用×来查询所有字段 SELECT * FROM DBO.tb1 --改为 SELECT FName,PWD,CreateDate FROM DBO.tb1 (NOLOCK) --2.查询数据行数SELECT COUNT(*) FROM tb1--改为 SELECT * FROM sysindexes WHERE id =OBJECT_ID('dbo.tb1') AND indid <2 --3.数字不要加引号,不然会全盘索引 SELECT * FROM DBO.tb1 (NOLOC
今天和大家简单分享几个实用的sql小技巧.还有一些还在整理中,会不断的分享出来. 有些其实也不算是sql的技巧,可能大家在写sql语句的时候没有意识到我们可以通过一条sql语句实现一些貌似复杂的功能. 首先来创建测试用表. create table test_obj as select *from dba_objects; 先随机抽出5条记录看看 set linesize 200 select object_id,object_name from test_obj where rownum O