表有三个字段编号,销售额,时间,要求自动生成100行数据
实现方法如下:
create table xiaoshou
(
xid int IDENTITY(1000,1),
xcount int,
xtime datetime
)
SET NOCOUNT ON
GO
DECLARE @MyCounter INT
SET @MyCounter = 0
Declare @n int
set @n=0
WHILE (@MyCounter < 100)
BEGIN
INSERT INTO xiaoshou(xcount,xtime) VALUES
(@MyCounter+1000,
DATEADD(day, @MyCounter, getdate())
)
SET @MyCounter = @MyCounter + 1
END
GO
SET NOCOUNT OFF
GO
实现方法如下:
create table xiaoshou
(
xid int IDENTITY(1000,1),
xcount int,
xtime datetime
)
SET NOCOUNT ON
GO
DECLARE @MyCounter INT
SET @MyCounter = 0
Declare @n int
set @n=0
WHILE (@MyCounter < 100)
BEGIN
INSERT INTO xiaoshou(xcount,xtime) VALUES
(@MyCounter+1000,
DATEADD(day, @MyCounter, getdate())
)
SET @MyCounter = @MyCounter + 1
END
GO
SET NOCOUNT OFF
GO