22,300
社区成员




Create proc Primarytestkey
as
declare @tel int
declare @qq int
set @tel=1
while(@tel<=10)
begin
set @qq=1
while(@qq<=10)
begin
---print @qq
insert into dbo.Uinfo values(@tel,@qq,default)
set @qq=@qq+1
end
set @tel=@tel+1
--print @tel
end
Create proc Primarytestkey
as
declare @tel int
declare @qq int
set @tel=1
while(@tel<=10)
begin
set @qq=1
while(@qq<=@tel)
begin
---print @qq
insert into dbo.Uinfo values(@tel,@qq,default)
set @qq=@qq+1
end
set @tel=@tel+1
--print @tel
end
declare @tel int=1
declare @qq int=1
while(@tel<=10)
begin
insert into Uinfo (tel,qq)
select @tel,@qq,default
set @qq=@qq+1
set @tel=@tel+1
end
while(@tel<=10)
begin
insert into dbo.Uinfo values(@tel,@qq,default)
set @qq=@qq+1
set @tel=@tel+1
end
create table uinfo(tel int, qq int)
go
Create proc Primarytestkey
as
declare @tel int
set @tel=1
while(@tel<=10)
begin
insert into Uinfo values(@tel,@tel) --defalut我取消了。
set @tel=@tel+1
end
go
exec Primarytestkey
select * from uinfo
drop proc Primarytestkey
drop table uinfo
/*
tel qq
----------- -----------
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
(所影响的行数为 10 行)
*/
---要的这样的结果?
QQ TEL
----------- -----------
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
(10 行受影响)
Create proc Primarytestkey
as
declare @tel int
declare @qq int
set @tel=1
set @qq=1
while(@tel<=10)
begin
insert into dbo.Uinfo values(@tel,@qq,default)
set @qq=@qq+1
set @tel=@tel+1
end