请问怎么建立视图能够让V.RecID有A.RecID的自增属性?
用ROW_NUMBER ()这个函数
如下:
create table ta(id int,name int)
insert ta select 1,2
union all select 1,3create view test_v
as
select *,row=ROW_NUMBER () over (order by id)
from taselect * from test_v
id name row
----------- ----------- --------------------
1 2 1
1 3 2(2 行受影响)
用ROW_NUMBER ()这个函数
如下:
create table ta(id int,name int)
insert ta select 1,2
union all select 1,3create view test_v
as
select *,row=ROW_NUMBER () over (order by id)
from taselect * from test_v
id name row
----------- ----------- --------------------
1 2 1
1 3 2(2 行受影响)
, A.Code, B.Code
FROM A JOIN B ON (A.Code = B.Code)
我想要的是原来[RecID]里的数据,还要取基表里[RecID]字段的元数据
用视图的方法,在SQL SERVER 2000 里我可以通过DELPHI查出[RecID]的元数据,判断[RecID]是不是自增型
但我把数据库移植到SQL SERVER 2005后就取不到[RecID]的某些元数据,不能判断[RecID]是不是自增型的,我想看一下是不是有什么方法可以兼容SQL SERVER 2000,SQL SERVER 2005,又能取到基表的数据,又能得到基础表的元数据,特别要取得自增列的元数据
下面连接有详细说明:
http://support.microsoft.com/kb/920974/