这个存储过程主要实现从tablename表中取出按orderby排序的第n行
判断表和列存在的相关判断未加上还- -
create procedure proc_nline -------取出tablename中按orderby排序的第n行数据
@n int, ----要取第几行
@tablename varchar(50), ---------表名
@orderby varchar(50) ---------排序列
as
if exists(select * from sysobjects where name ='NlineView')
drop view NlineView
exec('create view NlineView
as select top '+ @n +'* from '+@tablename+' order by '+@orderby)
exec('select top 1 * from NlineView order by '+@orderby+' desc')
用exec封装后,create view也能够在存储过程中被执行了