use pubs
go
if exists(select name from sysobjects where name='Title_pubs' and type='p')
drop procedure Title_pubsgocreate procedure Title_pubs
@pagemax int=5,
@pagesize int=1,
@cells intas if pagesize<>1
begin
select top @pagemax * from titles where title_id not in(select top @cells title_id from titles order by title_id asc) order by title_id asc
end
else
begin
select top @pagemax * from titles
end
go
if exists(select name from sysobjects where name='Title_pubs' and type='p')
drop procedure Title_pubsgocreate procedure Title_pubs
@pagemax int=5,
@pagesize int=1,
@cells intas if pagesize<>1
begin
select top @pagemax * from titles where title_id not in(select top @cells title_id from titles order by title_id asc) order by title_id asc
end
else
begin
select top @pagemax * from titles
end
解决方案 »
- SQL问题
- 求大侠指教!ret = SQLExecute(serverhstmt);中ret=-1是什么情况?
- 如何得到一个表与之对应的信息
- 无法初始化链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 的数据源对象。 开始的时候运行正常。
- 查询时报错,无法解决,求救!急……
- 如何用SQL语句完成指定的列的每一个数据加1
- 请教这个简单的SQL语句该怎么写?
- 这个查询语句应该怎么写?
- 如何判斷臨時表(如 #temp1 ) 存不存在?
- 请问SQL7与SQL2000有什么区别????
- 請問怎麼知道ms sql中正在進行哪些sql語句
- 求一条sql语句
go
if exists(select name from sysobjects where name='Title_pubs' and type='p')
drop procedure Title_pubsgocreate procedure Title_pubs
@pagemax int=5,
@pagesize int=1,
@cells intas if pagesize<>1
begin
exec('select top '+@pagemax+' * from titles where title_id not in(select top '+@cells+' title_id from titles order by title_id asc) order by title_id asc')
end
else
begin
exec('select top '+@pagemax+' * from titles')
end
go
if exists(select name from sysobjects where name='Title_pubs' and type='p')
drop procedure Title_pubsgocreate procedure Title_pubs
@pagemax int=5,
@pagesize int=1,
@cells intas if pagesize<>1
begin
exec('select top '+@pagemax+' * from titles where title_id not in(select top @cells title_id from titles order by title_id asc) order by title_id asc')
end
else
begin
exec('select top '+@pagemax+' * from titles')
end
go
if exists(select name from sysobjects where name='Title_pubs' and type='p')
drop procedure Title_pubsgocreate procedure Title_pubs
@pagemax int=5,
@pagesize int=1,
@cells intas if pagesize<>1
begin
exec ('select top '+ @pagemax +'* from titles where title_id not in(select top '+@cells +' title_id from titles order by title_id asc) order by title_id asc ')
end
else
begin
exec('select top ' +@pagemax+ ' * from titles')
end