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 (1, 1) NOT 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] 下一页 |