求大家帮小弟一个忙,看看这个存储过程哪错呢?
if (@assess_sort <> 0)
BEGIN
SET @SQL = @SQL + ' where a.assess_sort = '+Convert(varchar(5),@assess_sort)+ ') and a.assess_sort= '+Convert(varchar(5),@assess_sort)+ ' '
END
ELSE
SET @SQL =@SQL + ') '
END
if (@name <> ' ')
BEGIN
SET @SQL = @SQL + ' where a.assess_title LIKE ' '% '+@name+ '% ' ') and a.assess_title LIKE ' '% '+@name+ '% ' ' '
END
ELSE
SET @SQL =@SQL + ') '
END
EXECUTE (@SQL)
提示关键字 "END "附近有错.
------解决方案--------------------if (@assess_sort <> 0)
BEGIN --加这个进去
BEGIN
SET @SQL = @SQL + ' where a.assess_sort = '+Convert(varchar(5),@assess_sort)+ ') and a.assess_sort= '+Convert(varchar(5),@assess_sort)+ ' '
END
ELSE
SET @SQL =@SQL + ') '
END
if (@name <> ' ')
BEGIN --加这个进去
BEGIN
SET @SQL = @SQL + ' where a.assess_title LIKE ' '% '+@name+ '% ' ') and a.assess_title LIKE ' '% '+@name+ '% ' ' '
END
ELSE
SET @SQL =@SQL + ') '
END
EXECUTE (@SQL)
------解决方案--------------------begin end没套好.
if (@assess_sort <> 0)
BEGIN
SET @SQL = @SQL + ' where a.assess_sort = '+Convert(varchar(5),@assess_sort)+ ') and a.assess_sort= '+Convert(varchar(5),@assess_sort)+ ' '
END
ELSE
SET @SQL =@SQL + ') '
END
if (@name <> ' ')
BEGIN
SET @SQL = @SQL + ' where a.assess_title LIKE ' '% '+@name+ '% ' ') and a.assess_title LIKE ' '% '+@name+ '% ' ' '
END
ELSE
begin --这里少了一个.
SET @SQL =@SQL + ') '
END
EXECUTE (@SQL)