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.
Author |
Topic |
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2008-04-15 : 09:41:38
|
This my stored procedurealter PROCEDURE t @search varchar(200)AS SET NOCOUNT ONdeclare @str as varchar(1028)declare @str2 as varchar(128)declare @i as intdeclare @count as int set @str2 = 'PARSENAME(replace(replace(replace(rtrim(ltrim(' + replace(@search,'''','''''') + ')),'''' '''',''''<>''''),''''><'''',''''''''),''''<>'''','''' ''''),'set @str = ' where merchant_name LIKE ''''%'''' + ' + @str2 + '1) + ''''%'''' 'set @i = 1SET @Count = (select dbo.WordCount(@search))while @i <@countbeginset @i =@i +1set @str = @str + 'AND merchant_name LIKE ''''%'''' + ' + @str2 + cast(@i as varchar) + ') + ''''%'''' 'exec('select * from merchant ' + @str) endGOwhen i exec the above stored procedure as this--- exec t 'taj''s residency' its showing error ---- Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near ''.what is wrongthanks in advance |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-15 : 09:48:14
|
If you instead of executing the statement, just do aPRINT 'select * from merchant ' + @strand 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" |
 |
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2008-04-15 : 13:31:14
|
thanks peso |
 |
|
|
|
|
|
|