重复生成?

insert2003 2006-09-20 06:04:05
有如下表
tb_Test
c_No i_Sum
1234567 20
2345678 30
3456789 10
1111111 100
......

将c_No重复i_Sum次。就是要得到
1234567
1234567
1234567
1234567
.......共20行
2345678
2345678
2345678
2345678
......共30行
..........类推

请问应该怎能处理?
...全文
119 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
insert2003 2006-09-21
  • 打赏
  • 举报
回复
感谢
xyxfly 2006-09-20
  • 打赏
  • 举报
回复
跟一楼方法是一样的,呵呵,慢了
xyxfly 2006-09-20
  • 打赏
  • 举报
回复
给你写个类似的
create table t1(id int,num int)
insert t1 select 1,3 union all
select 2,2 union all
select 3,2

create table t2(id int,a1 int)

set rowcount 10
select id=identity(int,1,1) into #T from syscolumns
set rowcount 0

insert t2 select t1.id,#T.id from t1 left join #T on #T.id <= t1.num

select *from t2

正在吃饭,就不改了 ^_^
fcuandy 2006-09-20
  • 打赏
  • 举报
回复
create table tb(a varchar(10),b int)
insert tb select 1234567 ,20
union all select 2345678 ,30
union all select 3456789 , 10
union all select 1111111, 100

select top 100 identity(int) id into # from sysobjects,syscolumns
select a.* from tb a
inner join # b
on a.b>=b.id
drop table tb,#

34,590

社区成员

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

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