Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
LIKE - what's wrong
Message
 
To
28/04/2003 12:16:56
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00782298
Message ID:
00782301
Views:
11
You need to store your complete query into a variable and run it using sp_executeSQL:
declare @q nvarchar(500)

set @q = 'select * from authors'

exec sp_executesql @q 
>Hello All,
>I have been in the BOL and the following should work according to all that I have read, however, sample #1 does not work and sample #2 does work, any idea why? Also, they do not have full-text indexing so I can't use CONTAINS. TIA.
>
>Sample #1
>
>DECLARE @EvaluationID int, @SearchString char(100)
>
>SET @EvaluationID = 23
>SET @SearchString = '%quest%'
>
>SELECT DISTINCT( q.QuestionID ),
>	 q.QuestionText,
>	 d.html_description as AnswerDisplay
>FROM Questions q
>INNER JOIN Types t ON q.QuestionTypeID = t.TypeID
>		INNER JOIN DataGridCode d ON t.TypeID = d.TypeID
>	WHERE q.QuestionText LIKE @SearchString
>ORDER BY q.QuestionID
>
>
>
>Sample #2
>
>DECLARE @EvaluationID int, @SearchString char(100)
>SET @EvaluationID = 23
>
>SELECT DISTINCT( q.QuestionID ),
>	 q.QuestionText,
>	 d.html_description as AnswerDisplay
>FROM Questions q
>	INNER JOIN Types t ON q.QuestionTypeID = t.TypeID
>	INNER JOIN DataGridCode d ON t.TypeID = d.TypeID
>WHERE q.QuestionText LIKE '%quest%'
>ORDER BY q.QuestionID
>
>
>Thank you,
>Rhonda
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform