请各位大大进来看下这两个存储过程,有何改正之处??
各位大大分析一下下面两个过程,如果把表名当参数,在第一个里面拼凑SQL语句报错,
二
if exists( select * from sysobjects where name ='test')
drop procedure test
go
create procedure test
@RecordCount int output
as
select @RecordCount=COUNT(*) from UserTable
go
//下面是调用语句,可以正确得到想要的数量值
declare @RowCount int
exec test
@RecordCount = @RowCount OUTPUT
select @RowCount as RecordCount
二
if exists( select * from sysobjects where name ='test1')
drop procedure test1
go
create procedure test1
@tableName varchar(20),
@RecordCount int output
as
declare @Sqls nvarchar(2000)
set @Sqls='select '+LTRIM(@RecordCount)+' from '+LTRIM(@tableName)
exec(@Sqls)
go
//以下是调用方法,却得不到想要的值,返回的是NULL值
declare @RowCount int
exec test1
N'UserTable',
@RecordCount = @RowCount OUTPUT
select @RowCount as RecordCount
...全文
相关推荐
mysql存储过程实现计算两个时间相差,并用年月日时分秒格式输出
mysql获取两个时间相差年月日:使用mysql存储过程,实现计算两个时间的差值,并用年月日时分秒的格式输出,且从大到小为0时则不展示对应单位(如:相差1小时20秒 则展示'1时0分20秒')
sqlserver游标存储过程的使用
NULL 博文链接:https://gz383.iteye.com/blog/635513
两个分页存储过程的效率比较
两个分页存储过程的效率比较 详细的比较两个分页存储过程
地形改正_地形改正_重力_
利用常用的地形改正方式,加入自身的理解,建立模型,作地形改正
请各位领导移步到启动球前参考.doc
请各位领导移步到启动球前参考.doc


疑难问题

