March 5, 2004 at 2:21 am
hi
i have a situation in stored procedure where i get partial parameter so i have to use select query with like option but with parameter i will have to execute it in a string but when i execute it i get following error
Server: Msg 403, Level 16, State 1, Line 4
Invalid operator for data type. Operator equals modulo, type equals varchar.
My query is
CREATE PROC CM_SP_SelFireDistrictCode @fdt_v_firecode varchar(15)='OPT'--optional
As
declare @err int
declare @sstring varchar(500)
if @fdt_v_firecode ='OPT' --optional
Begin
select FDT_V_FIRECODE,FDT_V_DESC,FDT_V_COUNTY from ZCM_FDT_FIREDISTRICT
End
Else
@sstring='select FDT_V_FIRECODE,FDT_V_DESC,FDT_V_COUNTY from ZCM_FDT_FIREDISTRICT where FDT_V_FIRECODE like '%@fdt_v_firecode%''
print @sstring
exec @sstring
End
set @err =@@error
if @err<>0
return @err
GO
March 5, 2004 at 4:01 am
select @sstring='select FDT_V_FIRECODE,FDT_V_DESC,FDT_V_COUNTY from ZCM_FDT_FIREDISTRICT where FDT_V_FIRECODE like ''%'+@fdt_v_firecode+'%'''
March 5, 2004 at 4:40 am
Thanks WZ700 it works
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply