use Pages Pages是我建的数据库
create table MillionNews //我建的表
(
productID int identity(1,1) not null, //产品编号productName char(100), //产品名称unitPrice money //单价
)
GO//以下,我想生成1000条数据,但是成生后,发现产品名称变成了“产品 1”中间有8个空格,这是怎么回事,请高手帮忙解决
declare @@i int
set @@i=1
while @@i<=1000
begin
insert into MillionNews (productName,unitPrice) values ('产品'+str(@@i),11)
set @@i=@@i+1
end//对了,哪个高手能在begin end中用set @SQL='insert into ……'和exec(@SQL)来实现上面我想要效果,我不太会用SQL,请您多多帮助。
create table MillionNews //我建的表
(
productID int identity(1,1) not null, //产品编号productName char(100), //产品名称unitPrice money //单价
)
GO//以下,我想生成1000条数据,但是成生后,发现产品名称变成了“产品 1”中间有8个空格,这是怎么回事,请高手帮忙解决
declare @@i int
set @@i=1
while @@i<=1000
begin
insert into MillionNews (productName,unitPrice) values ('产品'+str(@@i),11)
set @@i=@@i+1
end//对了,哪个高手能在begin end中用set @SQL='insert into ……'和exec(@SQL)来实现上面我想要效果,我不太会用SQL,请您多多帮助。
@@b int
as
declare
@@a int
select @@a=1
while @@a<=@@b
begin
insert into MillionNews (productName,unitPrice) values('产品'+str(@@a,3),11)
set @@a=@@a+1
end
试试这个存储过程
然后exec A 1000
我试了没问题,希望能帮你 1000可以为你想要的记录数
如果要10000条记得把str(@@a,3)改为str(@@a,4)
declare @i int
set @i=1
while @i<=10
begin
print @i
set @i=@i+1
end
end
declare @i int
set @i=1
while @i<=10
begin
print 'aa'+convert(varchar(10),@i)
set @i=@i+1
end
end