日期:2014-05-16 浏览次数:20441 次
create table BookInfo
(
BookNo int,
BookName varchar(200),
Author nvarchar(200),
PublishDate date
)
declare @i int
set @i=0
while @i<1000
begin
insert into BookInfo values (@i,NEWID(),NEWID(),GETDATE()-RAND()*1000)
set @i=@i+1
end
--再说一下,存储过程不难,就是sql语句,不过加有变量参数之类的
--熟练了sql,存储过程的话,看一下人家的例子,半小时就学会了
WITH Digits AS (
SELECT 0 as Number
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9
)
SELECT
(d5.Number * 100000)
+ (d4.Number * 10000)
+ (d3.Number * 1000)
+ (d2.Number * 100)
+ (d1.Number * 10)
+ d0.Number as Number INTO #t
FROM
Digits AS d0
, Digits AS d1
, Digits AS d2
, Digits AS d3
, Digits AS d4
, Digits AS d5
ORDER BY Number