Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using CASE in a SQL 7 statement inside of a stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-27 : 16:24:39
Jason writes "Hello again,

I'm having a problem getting this case statement to run inside of a SQL 7 stored procedure.

SELECT DISTINCT TB.ID, TB.Title, TB.Summary, K.Rank =
Case @SearchSQL
When 'EntireDoc' Then 'INTO #Results FROM CONTAINSTABLE(tb_Main, *, @SearchPhrase) K'
Else 'INTO #Results FROM CONTAINSTABLE(tb_Main, Title, @SearchPhrase) K'
End
INNER JOIN tb_Main TB ON TB.ID = K.[Key]...

The error I'm getting is Server: Msg 170, Level 15, State 1, Procedure Search, Line 75
Line 75: Incorrect syntax near '='

According to BOL, the input_expression can be any valid MS SQL Server expression, which would include the variable @SearchSQL, but for some reason this isn't working.

Any ideas?

TiA,
Jason"
   

- Advertisement -