作为函数
Create Function F_GetNonIndividual(@SearchStr nVarchar(100)) Returns int
as -- use Select dbo.F_GetNonIndividual('Abc Solutions PVT LTD')
begin
Declare @Result int
Select @Result = Count(*)
from NonIndividualTitle
where @SearchStr Like ('%'+NonIndivTitle+'%')
Return @Result
end
作为程序
Create Procedure P_GetNonIndividual(@SearchStr nVarchar(100))
as -- use EXEC P_GetNonIndividual 'Abc Solutions PVT LTD'
begin
Select Count(*)
from NonIndividualTitle
where @SearchStr Like ('%'+NonIndivTitle+'%')
end
作为没有参数的程序
Create Procedure P_GetNonIndividualOut(@SearchStr nVarchar(100), @OutValue int out)
as
begin
Select @OutValue=Count(*)
from NonIndividualTitle
where @SearchStr Like ('%'+NonIndivTitle+'%')
end
带查询示例
Declare @OutValue int
exec P_GetNonIndividualOut 'Abc Solutions PVT LTD',@OutValue out
print @OutValue