关于存储过程参数传递的问题
我要实现的功能是
if ClassEName <> "" then
HotNewsSql = "Select *,NewsClass.FileExtName as ClassFileExtName,News.FileExtName as NewsFileExtName from News,NewsClass where News.ClassID=NewsClass.ClassID and DelTF=0 and News.AuditTF=1 and NewsClass.ClassEName='" & ClassEName & "' order by News.ClickNum Desc"
else
HotNewsSql = "Select *,NewsClass.FileExtName as ClassFileExtName,News.FileExtName as NewsFileExtName from News,NewsClass where News.ClassID=NewsClass.ClassID and DelTF=0 and News.AuditTF=1 order by News.ClickNum Desc"
end if
我的存储过程是这样写的
CREATE Procedure FS_ReFunHotNews
(@ClassEName varchar(100))
as
begin transaction
declare @TempSql varchar(1500)
Set @TempSql='Select *,NewsClass.FileExtName as ClassFileExtName,News.FileExtName as NewsFileExtName from News,NewsClass where News.ClassID=NewsClass.ClassID and DelTF=0 and News.AuditTF=1'+@ClassEName+' order by News.ClickNum Desc'
exec(@TempSql)
if @@error=0
commit transaction
else
rollback transaction
return
GO
我要问的是
我怎么把参数 and NewsClass.ClassEName='" & ClassEName & "'传进去
或者改存储过程也行,怎么改?
if ClassEName <> "" then
HotNewsSql = "Select *,NewsClass.FileExtName as ClassFileExtName,News.FileExtName as NewsFileExtName from News,NewsClass where News.ClassID=NewsClass.ClassID and DelTF=0 and News.AuditTF=1 and NewsClass.ClassEName='" & ClassEName & "' order by News.ClickNum Desc"
else
HotNewsSql = "Select *,NewsClass.FileExtName as ClassFileExtName,News.FileExtName as NewsFileExtName from News,NewsClass where News.ClassID=NewsClass.ClassID and DelTF=0 and News.AuditTF=1 order by News.ClickNum Desc"
end if
我的存储过程是这样写的
CREATE Procedure FS_ReFunHotNews
(@ClassEName varchar(100))
as
begin transaction
declare @TempSql varchar(1500)
Set @TempSql='Select *,NewsClass.FileExtName as ClassFileExtName,News.FileExtName as NewsFileExtName from News,NewsClass where News.ClassID=NewsClass.ClassID and DelTF=0 and News.AuditTF=1'+@ClassEName+' order by News.ClickNum Desc'
exec(@TempSql)
if @@error=0
commit transaction
else
rollback transaction
return
GO
我要问的是
我怎么把参数 and NewsClass.ClassEName='" & ClassEName & "'传进去
或者改存储过程也行,怎么改?
...全文
相关推荐
将逗号分隔的参数传递给存储过程
如何将整数数组传递给存储过程。
MyBatis调用存储过程
怎么使用MyBatis调用存储过程,步骤详细清楚,一看就会配置
Mybatis传list参数调用oracle存储过程的解决方法
怎么利用MyBatis传List类型参数到数据库存储过程中实现批量插入数据?接下来通过本文给大家介绍Mybatis传list参数调用oracle存储过程,需要的朋友可以参考下
SQL实现递归及存储过程中In()参数传递解决方案详解
1.SQL递归 在SQL Server中,我们可以利用表表达式来实现递归算法,一般用于阻止机构的加载及相关性处理。 –>实现: 假设OrganiseUnit(组织机构表)中主要的三个字段为OrganiseUnitID(组织机构主键ID)、ParentOrganiseUnitID(组织机构父ID)、OrganiseName(组织机构名称) 代码如下:with organise as(select * from OrganiseUnit where OrganiseUnit.OrganiseUnitID = @OrganiseUnitID union all select OrganiseUnit
在cognos中调用存储过程的结果集来生成报表遇到的报错和解决方法
本人在cognos中调用存储过程的结果集来生成报表遇到的报错和解决方法。很实用


