如果你的表有primary key 或唯一索引, 你可以使用一下查询'select @aa=numrows from sysindexes where objectid = (select objectid from sysobjects where name = '+@tab_var+ ') and type=P' 取得记录数,效率要高一些
'select @aa=numrows from sysindexes where objectid = (select objectid from sysobjects where name = '+@tab_var+ ') and type=P'这里的变量@aa在执行的时候,会有提示,没有申明,另外即使申明了,在执行完成后,也自动撤消了,不会交给接下来的程序使用!
你可以使用一下查询'select @aa=numrows from sysindexes
where objectid = (select objectid from sysobjects where name = '+@tab_var+
') and type=P'
取得记录数,效率要高一些
where objectid = (select objectid from sysobjects where name = '+@tab_var+
') and type=P'这里的变量@aa在执行的时候,会有提示,没有申明,另外即使申明了,在执行完成后,也自动撤消了,不会交给接下来的程序使用!