View Code
1 GO
2 /****** Object: StoredProcedure [dbo].[UP_General_GetRowCount] Script Date: 03/17/2011 11:17:19 ******/
3 SET ANSI_NULLS ON
4 GO
5 SET QUOTED_IDENTIFIER ON
6 GO
7 ALTER PROCEDURE [dbo].[UP_General_GetRowCount]
8 @strTable nvarchar(255), -- 表名
9 @strField nvarchar(1000) = '*', -- 需要返回的列
10 @strWhere nvarchar(255)='', -- 排序的字段名
11 @RowCount int output -- 返回记录总数
12 AS
13
14
15 declare @strSQL nvarchar(4000) -- 主语句
16 set @strSQL = 'select @RowCount=ISNULL(count(*),0) from ' + @strTable + ' where 1=1 '+@strWhere
17 exec sp_executesql @strSQL,N'@RowCount int output',@RowCount out