怎样给一个表加上行号? 现有一表,已有数据过万,我想在此表加一个列,用于记录每条记录所在表的行数,请问各们有没什么好办法,谢谢,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select *,identity(int,1,1) as 行数 into Table2 from table1 create table tb(name varchar(10))insert into tb select 'aa'insert into tb select 'vaa'insert into tb select 'aad'insert into tb select 'ada'goalter table tb add 行数 int identity(1,1)goselect * from tbdrop table tb eddy8863(西北狂) 你的方法不太好吧,那我不是又要重新建个表,xeqtr1982(vesslan) 标识列怎么运用 --你可以运行一下看看create table tb(name varchar(10))insert into tb select 'aa'insert into tb select 'vaa'insert into tb select 'aad'insert into tb select 'ada'goselect * from tbgoalter table tb add 行数 int identity(1,1)goselect * from tbdrop table tb 没把握的话,可以新建一个和你的数据表完全一样的表测试一下select * into 表2 from 表1 alter table tb add 行数 int identity(1,1)这里的"行数"是你新增的列名,可以修改为其他因为这个列是个标识列,所以当数据增加时可以自动增加在以后向表中添加数据时,不能向这个列插入值,否则会提示错误 xeqtr1982(vesslan) 的方法不错,谢谢,谢谢! xeqtr1982(vesslan) ( ) 信誉:100 同意 请教一个SQL问题 查询表中Name 相同的数据并列出来 按Age排序 请教关于SQL交叉 插入数据 求case表达式 不得其解,查询和存储过程就有这么大的差异?? 真愁人一直安装不上 求关于IP地址的SQL写法 存储过程出了点问题?不知道那里错了? 一个FOXBASE的打印问题。 未与信任 SQL Server 连接相关联 存储过程怎么返回一个数据集合? 怎样向数据库里插如1,2,3,4,5,6这样的数据,和读取.谢谢各位
insert into tb select 'aa'
insert into tb select 'vaa'
insert into tb select 'aad'
insert into tb select 'ada'
goalter table tb add 行数 int identity(1,1)
goselect * from tbdrop table tb
create table tb(name varchar(10))
insert into tb select 'aa'
insert into tb select 'vaa'
insert into tb select 'aad'
insert into tb select 'ada'
goselect * from tb
goalter table tb add 行数 int identity(1,1)
goselect * from tbdrop table tb
这里的"行数"是你新增的列名,可以修改为其他
因为这个列是个标识列,所以当数据增加时可以自动增加
在以后向表中添加数据时,不能向这个列插入值,否则会提示错误
同意