打印本文 打印本文 关闭窗口 关闭窗口
整理了一些t-sql技巧
作者:武汉SEO闵涛  文章来源:敏韬网  点击数16761  更新时间:2007/11/14 13:12:55  文章录入:mintao  责任编辑:mintao
bsp;           when 5 then 2
                  
when 1 then 3
                  
when 2 then 4
                  
when 3 then 5 end


2、 第二种

select * from t order by (id+2)%6


3、 第三种

select * from t order by charindex(cast(id as varchar),''''45123'''')


4、 第四种

select * from t
WHERE id between 0 and 5
order by charindex(cast(id as varchar),''''45123'''')


5、 第五种

select * from t order by case when id >3 then id-5 else id end


6、 第六种

select * from t order by id / 4 desc,id asc

 

十、 一条语句删除一批记录
首先id列是int标识类类型,然后删除ID值为5,6,8,9,10,11的列,这里的cast函数不能用convert函数代替,而且转换的类型必须是varchar,而不能是char,否则就会执行出你不希望的结果,这里的"5,6,8,9,10,11"可以是你在页面上获取的一个chkboxlist构建成的值,然后用下面的一句就全部删
除了,比循环用多条语句高效吧应该。

 << 上一页  [11] [12] [13] [14] [15] [16] [17] [18] [19]  下一页

打印本文 打印本文 关闭窗口 关闭窗口