ALTER PROCEDURE [dbo].[AirWayBillsSelectByManifestNumbers] >( > @awb_manifestnumber varchar(100) >) >AS > SET NOCOUNT ON; > >SELECT [awb_pk] > ,[awb_keycode] > ,[awb_manifestdate] > ,[awb_manifestnumber] > ,[awb_pieces] > ,[awb_weight] > ,[awb_cusfk] > ,[awb_value] > ,[awb_freight] > ,[awb_fuel] > ,[awb_insurance] > ,[awb_number] > ,[awb_shipper] > ,[awb_description] > ,[cus_number] > FROM [dbo].[AirWayBills] > inner join [dbo].[Customers] on awb_cusfk = cus_PK > WHERE > ([awb_manifestnumber] IN (@awb_manifestnumber))>
ALTER PROCEDURE [dbo].[AirWayBillsSelectByManifestNumbers] >( > @awb_manifestnumber varchar(100) >) >AS > SET NOCOUNT ON; > >if object_id('tepmdb..#awblist',N'U') IS NOT NULL drop table #awblist; > >select int_value > into #awblist > from dbo.fn_ParseText2Table(@awb_manifestnumber, ',') > >SELECT [awb_pk] > ,[awb_keycode] > ,[awb_manifestdate] > ,[awb_manifestnumber] > ,[awb_pieces] > ,[awb_weight] > ,[awb_cusfk] > ,[awb_value] > ,[awb_freight] > ,[awb_fuel] > ,[awb_insurance] > ,[awb_number] > ,[awb_shipper] > ,[awb_description] > ,[cus_number] > FROM [dbo].[AirWayBills] > inner join [dbo].[Customers] on awb_cusfk = cus_PK > inner join #awblist on #awblist.int_value = awb_manifestnumber>
CREATE FUNCTION [dbo].[isIN] ( @lcStr varchar(100) , @lcList varchar(max) ) RETURNS int AS BEGIN DECLARE @Test int = 0 if @lcStr = '' or @lcList='' set @test=1 else if NOT (@lcStr is null or @lcList is null) begin declare @aa int set @aa = charindex(','+@lcStr+',',','+@lcList+',') if @aa>0 set @Test = 1 else set @test = 0 end RETURN @Test END GOthen, in the conditional clause I would
WHERE dbo.isIN([awb_manifestnumber], @awb_manifestnumber)>0