declare @i int , @m varchar(32),@j varchar(32),@whid int ,@whpcode int ,@q int ,@p int set @i=0 set @m='列' set @j='组' set @whid=98 ----查询表dbo.AF_WAREHOUSEPLACE中WHID的最大值后加上1 set @whpcode=1080101 ----修改成对应柜号,例如:1080101的前三位是库柜编号108 ,可在表dbo.AF_WAREHOUSE中查询 set @q=1 set @p=1 while @i<46 begin while @q<15 begin while @p<7 begin --- 把表 test 改成 dbo.AF_WAREHOUSEPLACE insert into TEST(WHID,STATE,WHPCODE,WHPNAME,CLASSID) VALUES(@whid,0,convert(varchar(24),@whpcode),convert(varchar(32),@q)+@m+convert(varchar(32),@p)+@j,7) set @p=@p +1 set @whpcode=@whpcode +1 end set @q=@q +1 set @p=1 set @whpcode=@whpcode+94 end set @whid=@whid +1 set @i=@i+1 set @q=1 set @whpcode=1080101+@i*10000 end