日期:2014-05-18  浏览次数:20502 次

请教有关like用法的一个问题!
alter   proc   p_FineMood
@Mood       varchar(30)
as
exec
( 'alter   view   v_FineMood
as
SELECT   TOP   20   MoodInfo,MoodName
FROM     Mood
WHERE   cast(MoodName   AS   varchar(10))   LIKE   '%+@Mood+% ' ')

在我每次调试之后,总提示如下的错误信息:第   9   行:   '% '   附近有语法错误。
请教高手给予指点,谢谢!

------解决方案--------------------
cast(MoodName AS varchar(10)) LIKE ' '% '+@Mood+ '% ' ' '
------解决方案--------------------
alter proc p_FineMood
@Mood varchar(30)
as
exec
( 'alter view v_FineMood
as
SELECT TOP 20 MoodInfo,MoodName
FROM Mood
WHERE cast(MoodName AS varchar(10)) LIKE ' '% ' ' '+@Mood+ '% ' ' ')