RowCount

来源:互联网 发布:linux远程连接oracle 编辑:程序博客网 时间:2024/04/23 19:38

--首次看到ROWCOUNT的用法

 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[aa]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[aa]
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS OFF
GO

CREATE procedure dbo.aa
(
   @aa    nvarchar(20) ,
   @bb  nvarchar(20),
  @cc int
)
as
declare @SqlString as nvarchar(1000)
begin
set @SqlString='select top '+ @bb+ ' * from (  Select  top ' +@aa  +'  *  from Application order by applicationID ) v order by ID'
SET ROWCOUNT @cc
execute sp_executesql @SqlString

end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO