|
akpaga
Constraint Violating Yak Guru
USA
283 Posts |
Posted - 04/15/2008 : 09:41:38
|
This my stored procedure
alter PROCEDURE t @search varchar(200) AS SET NOCOUNT ON declare @str as varchar(1028) declare @str2 as varchar(128) declare @i as int declare @count as int
set @str2 = 'PARSENAME(replace(replace(replace(rtrim(ltrim(' + replace(@search,'''','''''') + ')),'''' '''',''''<>''''),''''><'''',''''''''),''''<>'''','''' ''''),' set @str = ' where merchant_name LIKE ''''%'''' + ' + @str2 + '1) + ''''%'''' '
set @i = 1 SET @Count = (select dbo.WordCount(@search))
while @i <@count begin
set @i =@i +1 set @str = @str + 'AND merchant_name LIKE ''''%'''' + ' + @str2 + cast(@i as varchar) + ') + ''''%'''' '
exec('select * from merchant ' + @str) end
GO
when i exec the above stored procedure as this --- exec t 'taj''s residency' its showing error ---- Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near ''.
what is wrong
thanks in advance |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 04/15/2008 : 09:48:14
|
If you instead of executing the statement, just do a
PRINT 'select * from merchant ' + @str
and copy the output, what do you see that is wrong? When you try to run the copied output which error do you get.
Now fix them.
E 12°55'05.25" N 56°04'39.16" |
 |
|