你准备要生成什么样的数据呀
批量插入
无非就用
select * into 新表 from 旧表
insert into 新表 select * from 旧表
批量插入
无非就用
select * into 新表 from 旧表
insert into 新表 select * from 旧表
解决方案 »
- 请教各位大侠,如何学好sql server数据库管理呢?
- 用VC调用openrowset从SQLServer导出查询的数据到Access, 结果这个程序不能在客户端电脑使用,解决就给分
- sql问题
- 有个一次插入多行的SQL语句,急急急!!!各位达人帮帮忙啊!!
- sql server 不能连接上!
- 最简单sql语句的问题
- 表可以分组吗?
- 两张表关联操作
- 备份数据库的存储过程怎么写?程序里怎么调用
- 身边实在没有资料。问一个菜问题:在SQLSERVER的存储过程中,定义了个Cursor。如何让它直接到末尾?我想取数据集的最后一条数据
- 请问我如何在一个数据库中建立和另一数据库中的某表结构完全相同的表?用程序实现。
- 数据库设计 有关主键的问题!!!
批量插入嘛
无非用select * into newtable from oldtable
insert into newtable select * from oldtable
declare @i int
set @i = 1
while @i <= 10
begin
insert into 新表 select 数量字段*@i,其它字段 from 旧表
set @i = @i + 1
end
set @i=1while @i<1000
begin
insert into tablename select * from tablename
set @i=@i+1
end
set @i=1while @i<1000
begin
insert into tablename select * from tablename
set @i=@i+1
end
GO
SET ANSI_NULLS ON
GOCREATE Proc sp_person_isp as
declare @i int
set @i = 1
while @i <= 100
begin
insert into aaaa select cG_BarCode+@i,cG_Name,cG_Code,cClassCode,cG_Spec, cG_Area ,cG_Unit, cG_Box, fG_BCount, cShelfCode, cWareCode, dG_Date,
dG_Tag ,dG_Time ,mG_Uprice ,mG_Ucost, fG_Rate,cG_CounterCode ,cG_DeptCode, cG_Type ,cSp_Code, bAutoMove ,bAutoStock,
iW_Max ,iW_Min,fSaleCount, iW_DayCount mG_Mppicea , cG_Style ,iG_Day,fG_CostRate, cG_Brand ,iG_DateNum , cG_Package ,
cG_Ratify ,cG_Lable,mP_Uprice1,mP_Uprice2,mP_Uprice3,fG_Count2,fP_Count3,iG_DayNum,dP_BegDate,dP_EndDate,dP_BegTime,dP_EndTIme,
bSendAcc, dg_time2 , mg_newcost,mg_oldcost, dp_sl1,dp_sl2, dp_sl3 , dp_sl4,mp_sluprice1,mp_sluprice2,mp_sluprice3 from gpinfo
set @i = @i + 1
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO--为什么我在运行的时候出现以下的提示
服务器: 消息 213,级别 16,状态 4,过程 sp_person_isp,行 7
插入错误: 列名或所提供值的数目与表定义不匹配。
请前辈赐教!!!!
declare @i int
set @i=0
while @i<1000
begin
insert into aaaa select cG_BarCode+@i,cG_Name,...from gpinfo
where cG_BarCode>0 and cG_BarCode<=100
set @i = @i + 100
end
这样便会产生100000条数据了