62,254
社区成员
发帖
与我相关
我的任务
分享
create proc GetPr
(
@productname varchar(20),
@serialnumber varchar(20)
)
as
declare @sqlstr varchar(1000)
set @sqlstr ='SELECT p.productid,p.catid, p.productname, p.serialnumber, p.price, p.curprice, p.discount,
(select TOp 1 imagefile from productimage where productid=p.productid and priority=(case when (select Count(*) from productimage
where productid=p.productid and priority=1)>0 then 1 else 0 end )) AS imagefile, (SELECT top 1 whratio FROM productimage WHERE productid =
p.productid) AS whratio FROM productinfo p INNER JOIN category c ON p.catid = c.catid where 1=1 '
if(@productname<>'')
begin
@sqlstr=@sqlstr+'and p.productname like '+'%'+@productname+'%'''end
if(@serialnumber<>'')
begin
@sqlstr=@sqlstr+'and p.serialnumber like '+'%'+@serialnumber+'%'end
print @sqlstr
exec(@sqlstr)
服务器: 消息 170,级别 15,状态 1,过程 GetPr,行 14
第 14 行: '@sqlstr' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,过程 GetPr,行 18
第 18 行: '@sqlstr' 附近有语法错误。
create proc GetPr
(
@productname varchar(20),
@serialnumber varchar(20)
)
as
declare @sqlstr varchar(1000)
set @sqlstr ='SELECT p.productid,p.catid, p.productname, p.serialnumber, p.price, p.curprice, p.discount,
(select TOp 1 imagefile from productimage where productid=p.productid and priority=(case when (select Count(*) from productimage
where productid=p.productid and priority=1)>0 then 1 else 0 end )) AS imagefile, (SELECT top 1 whratio FROM productimage WHERE productid =
p.productid) AS whratio FROM productinfo p INNER JOIN category c ON p.catid = c.catid where 1=1 '
if(@productname<>'')
begin
set @sqlstr=@sqlstr+'and p.productname like '+'%'+@productname+'%''' end
if(@serialnumber<>'')
begin
set @sqlstr=@sqlstr+'and p.serialnumber like '+'%'+@serialnumber+'%'end
print @sqlstr
exec(@sqlstr)
create proc GetPr
(
@productname varchar(20),
@serialnumber varchar(20)
)
as
declare @sqlstr varchar(1000)
set @sqlstr ='SELECT p.productid,p.catid, p.productname, p.serialnumber, p.price, p.curprice, p.discount,
(select TOp 1 imagefile from productimage where productid=p.productid and priority=(case when (select Count(*) from productimage
where productid=p.productid and priority=1)>0 then 1 else 0 end )) AS imagefile, (SELECT top 1 whratio FROM productimage WHERE productid =
p.productid) AS whratio FROM productinfo p INNER JOIN category c ON p.catid = c.catid where 1=1 '
if(@productname<>'')
begin
set @sqlstr=@sqlstr+'and p.productname like '+'%'+@productname+'%''' end
if(@serialnumber<>'')
begin
set @sqlstr=@sqlstr+'and p.serialnumber like '+'%'+@serialnumber+'%'end
print @sqlstr
exec(@sqlstr)
服务器: 消息 170,级别 15,状态 1,过程 GetPr,行 14
第 14 行: '@sqlstr' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,过程 GetPr,行 18
第 18 行: '@sqlstr' 附近有语法错误。
create proc GetPr
(
@productname varchar(20),
@serialnumber varchar(20)
)
as
declare @sqlstr varchar(1000)
set @sqlstr ='SELECT p.productid,p.catid, p.productname, p.serialnumber, p.price, p.curprice, p.discount,
(select TOp 1 imagefile from productimage where productid=p.productid and priority=(case when (select Count(*) from productimage
where productid=p.productid and priority=1)>0 then 1 else 0 end )) AS imagefile, (SELECT top 1 whratio FROM productimage WHERE productid =
p.productid) AS whratio FROM productinfo p INNER JOIN category c ON p.catid = c.catid where 1=1 '
if(@productname<>'')
begin
@sqlstr=@sqlstr+'and p.productname like '+'%'+@productname+'%'''
end
if(@serialnumber<>'')
begin
@sqlstr=@sqlstr+'and p.serialnumber like '+'%'+@serialnumber+'%'
end
print @sqlstr
exec(@sqlstr)