ITPub博客

首页 > 数据库 > SQL Server > SQL Server 2008一个酷酷的函数:fn_PhysLocFormatter,返回记录的rowid

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

原创 SQL Server 作者:lawzjf 时间:2009-05-31 15:18:43 0 删除 编辑

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博客 ” ,链接:https://blog.itpub.net/37724/viewspace-1022632/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-18

  • 博文量
    279
  • 访问量
    991219