打印本文 打印本文 关闭窗口 关闭窗口
整理了一些t-sql技巧
作者:武汉SEO闵涛  文章来源:敏韬网  点击数16987  更新时间:2007/11/14 13:12:55  文章录入:mintao  责任编辑:mintao
  select 1 from [tb] where [pid]=a.[id])
--*/
 
return
end
go

--调用(查询所有的子)
select a.*,层次=b.[level] from [tb] a,f_cid(2)b where a.[id]=b.[id]
go

--删除测试
drop table [tb]
drop function f_cid
go

 

九、 排序问题

CREATE TABLE [t] (
 
[id] [int] IDENTITY (11NOT NULL ,
 
[GUID] [uniqueidentifier] NULL 
ON [PRIMARY]
GO


下面这句执行5次

insert t values (newid())


查看执行结果

select * from t


1、 第一种

select * from t
 
order by case id when 4 then 1
      &n

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

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