有关插入某列数值的问题

ldl999 2004-09-02 07:18:02
现有这样一个表,
字段为
seq eid tel time used 等5个字段
现在我想插入eid 列100001到165536
used都设为0
请教高手怎么做好些
...全文
80 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackting 2004-09-02
  • 打赏
  • 举报
回复
declare @i int
set @i=100001
while @i<165536
begin
insert into #tabl (seq , eid, tel, time, used ) select
identity(int,1,1),@i,'','',0
set @i=@i+1
end
pbsql 2004-09-02
  • 打赏
  • 举报
回复
楼上的要执行65536个insert,效率低下
pbsql 2004-09-02
  • 打赏
  • 举报
回复
难道不符合吗?呵呵
jackting 2004-09-02
  • 打赏
  • 举报
回复
declare @i int
set @i=100001
while @i<165536
begin
insert into 表(eid, used ) select @i,0
set @i=@i+1
end
ldl999 2004-09-02
  • 打赏
  • 举报
回复
按找我这个要求呢 ,呵呵
ldl999 2004-09-02
  • 打赏
  • 举报
回复
结果为这样
seq eid tel time used
1 100001 0
2 100002 0
3 100003 0
......
65536 165536 0
pbsql 2004-09-02
  • 打赏
  • 举报
回复
select top 65536 identity(int,100001,1) id into #t
from sysobjects a,sysobjects b,sysobjects c
insert into tablename(eid,used)
select id,0 from #t
drop table #t

34,838

社区成员

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

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