SQL Server 2008一个酷酷的函数:fn_PhysLocFormatter,返回记录的rowid

1> create table t(a int identity, b char(5) default 'x')
2> go
1> insert into t default values
2> go 5

1> select sys.fn_PhysLocFormatter(%%physloc%%) as RID, * from t
2> go
RID a b
---------- ----------- -----
(1:21:0) 1 x
(1:21:1) 2 x
(1:21:2) 3 x
(1:21:3) 4 x
(1:21:4) 5 x

与Oracle的DBMS_ROWID包中的函数功能相同,但是这个更好用。

另外一个函数是sys.fn_physLocCracker ,其用法如下:

1> create table t(a int)
2> insert into t values(1)
3> insert into t values(2)
4> insert into t values(3)
5> insert into t values(4)
6> go

1> select * from t Cross Apply sys.fn_physLocCracker (%%physloc%%) AS plc;
2> go
a file_id page_id slot_id
----------- ----------- ----------- -----------
1 1 278 0
2 1 278 1
3 1 278 2
4 1 278 3

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/37724/viewspace-1022632/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/37724/viewspace-1022632/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值