复制代码 代码如下:
/***************创建测试表*********************
****************downmoo 3w@live.cn ***************/
IF NOT OBJECT_ID('[Demo_Top]') IS NULL
DROP TABLE [Demo_Top]
GO
Create table [Demo_Top]
(PID int identity(1,1) primary key not null
,PName nvarchar(100) null
,AddTime dateTime null
,PGuid Nvarchar(40)
)
go
truncate table [Demo_Top]
/***************创建1002条测试数据*********************
****************downmoo 3w@live.cn ***************/
declare @d datetime
set @d=getdate()
declare @i int
set @i=1
while @i<=1002
begin
insert into [Demo_Top]
select cast(datepart(ms,getdate()) as nvarchar(3))+Replicate('A',datepart(ss,getdate()))
,getdate()
,NewID()
set @i=@i+1
end
复制代码 代码如下:
Declare @percentage float
set @percentage=1
select Top (@percentage) percent PName from [Demo_Top] order by PName
--注意是11行。(11 row(s) affected)
复制代码 代码如下:
select PName,AddTime, PGuid from [Demo_Top]
TableSample System(10 percent)
--(77 row(s) affected)
复制代码 代码如下:
while (select count(1) from [Demo_Top])>0
begin
delete top (202) from [Demo_Top]
end
/*
(202 row(s) affected)
(202 row(s) affected)
(202 row(s) affected)
(202 row(s) affected)
(194 row(s) affected)
*/
新闻热点
疑难解答