ALTER proc GetDataByNumCategory
(
@Carcategory nvarchar(50)
)
as
declare @sql nvarchar(1000)
declare @Num nvarchar(20)
set @Num=(select top 1 Keyword from TaoCarActive)
declare @Green nvarchar(100)
declare @Green1 nvarchar(100)
set @Green='<span style="color:Green;">'
set @Green1='</span>'
declare @Red nvarchar(100)
set @Red='<span style="color:Red;">'
declare @Red1 nvarchar(100)
set @Red1='</span>'
exec('select top '+@Num+'
ID,
case when Hits=0 then '''+@Green+'''+CarCard+'''+@Green1+'''
else '''+@Red+'''+CarCard+'''+@Red1+''' end as CarCard
from
TaoCarActive where Carcategory='''+@Carcategory+''' order by ID')
创建表格并添加300万数据 use Stored CREATE TABLE UserInfo( --创建表 id int IDENTITY(1,1) PRIMARY KEY not null,--添加主键和标识列 UserName varchar(50) ) declare @i int --添加3百万数据,大概4分钟时间 set @i=1 while @i<3000000 begin insert into UserInfo (UserName) values(@i) set @i=@i+1