Am getting the following error message and do not understand why.
Msg 402, Level 16, State 1, Line 21 - The data types varchar and varchar are incompatible in the modulo operator. I have validated part of the code as indicated below. I am new to this enviroment so any explanation as to why the code is worng is greatly apprecieated
Code being used -
declare @tabtemp table (i int identity, sl_effected_user_id varchar(20)null)
declare @rows int
declare @var1 as varchar(20)
declare @query as varchar(8000)
insert into @tabtemp
select sl_effected_user_id
from table1
----------------------------I have validated to here and all is good
Select @rows = @@ROWCOUNT
While @rows >0
Begin
Select @var1 = sl_effected_user_id
from @tabtemp WHERE i = @Rows
set @query = '
insert into table3
select sl_id, sys_creation_date, operator_id, application_id, sl_app_id,
sl_effected_environment, sl_effected_profile_id, sl_effected_user_id,
sl_location, sl_event_description
from table2
where sl_effected_user_id like ('% +@var1+ ')
'
print @query
SET @Rows = @Rows -1
exec (@query)
END
insert into table3
select sl_id, sys_creation_date, operator_id, application_id, sl_app_id,
sl_effected_environment, sl_effected_profile_id, sl_effected_user_id,
sl_location, sl_event_description
from table2
where sl_effected_user_id like '+'''% '+@var1+ ''''