高手请问:我想在数据表中的第10行前面插入一行怎么实现?

huang_jihua 2002-07-15 04:11:35
请举例说明,谢谢
...全文
125 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
OpenVMS 2002-07-16
  • 打赏
  • 举报
回复
哈哈,是不是逻辑上显示的效果?

如果你的表没有IDENTITY列,你可以这样
select * into #t from t2
alter table #t add id int identity(1,2)
go
set identity_insert #t on
go
insert #t(name,num,id) values('before10',30,18)
truncate table t2
go
insert into t2 select name,num from #t order by id
drop table #t
go
select * from t2
go


results:
name num
---------- -----------
老张人 210
ok 110
hi 20
alove 110
NULL NULL
-- 0
NULL NULL
a 80
a 2
before10 30
test 30
b 10
alove 110
ok 90
b 30

(15 row(s) affected)
liupingsk 2002-07-16
  • 打赏
  • 举报
回复
我觉得帖主是受FOX的影响了,应该摆脱这种以前的思维方式。
wzsswz 2002-07-16
  • 打赏
  • 举报
回复
转牛角尖!
byrrj 2002-07-15
  • 打赏
  • 举报
回复
没有用的,你设置了主键后,数据库会自动排记录的,即不能控制插入到那一行。
j9988 2002-07-15
  • 打赏
  • 举报
回复
好吧!你试试:
select top 9 * into #temp1 from tablename
delete from tablename where id in (select top 9 id from tablename)
select * into #temp2 from tablename
go
TRUNCATE TABLE tablename
go
insert into tablename select * from #temp1
insert into tablename (你插入的行)
insert into tablename select * from #temp2
tofool 2002-07-15
  • 打赏
  • 举报
回复
试一下fetch ,有时好像可以
huang_jihua 2002-07-15
  • 打赏
  • 举报
回复
我现在就是要这么做,请问怎么实现?请举例,谢谢
newly_ignorant 2002-07-15
  • 打赏
  • 举报
回复
Up
但是也可以硬生生地模拟实现
steper 2002-07-15
  • 打赏
  • 举报
回复
没有“在数据表中的第几行前面插入一行”的概念,数据插入表以后都是一样的,只有查询数据时按何种方式排序的概念。
anythingbutgirl 2002-07-15
  • 打赏
  • 举报
回复
概念同上
CSDNM 2002-07-15
  • 打赏
  • 举报
回复
没有“在数据表中的第10行前面插入一行”的概念,数据插入表以后都是一样的,没有次序概念。

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧