Sql Server - How to have Multiple IF Condition in Table Valued Functions
How to have Multiple IF Condition in Table Valued Functions
(
@Parameter1 as varchar(2) ,
@Parameter2 as integer
)
RETURNS @mytable table
(
CountOfRecords int
)
As
Insert into @mytable (CountOfRecords)
Select count(*) as CountOfRecords from TestTable where FieldOne is null
and Field2= @Parameter2
Insert into @mytable (CountOfRecords)
Select count(*) as CountOfRecords from TestTable where FieldOne is null
and Field2 = @Parameter2
else if (@Parameter1 ='SN')
Insert into @mytable (CountOfRecords)
Select count(*) as CountOfRecords from TestTable where FieldOne is null
and Field2= @Parameter2
RETURN
end
Comments
Post a Comment