Variable Syntax for User Input

  • Create proc MyProc @Operator as varchar(2), @EquipmentCount as INT,

    AS

    Set nocount on

    select count (*) as carrier_count from dbo.v_MTSTM_EquipmentCountByCarrier where 0 <

    case when @Operator = '<' and equipment_count ' and equipment_count > @EquipmentCount then 1

    when @Operator = '=' and equipment_count = @EquipmentCount then 1

    ...

    else 0 end

    set nocount off

  • SET @sSQL =  @Statement + @Operator + CONVERT(nvarchar,@EquipmentCount)

    Andy

  • You don't need dynamic sql to do this task, please stay away from it.

  • Thanks for the suggestions. Dynamic SQL is new to me. I still have been unsuccessfull. I need to read about the code both of you have supplied so I may understand exactly what is happening. I'll post what I end up with. And feel free to post any other suggestions! Thanks again for your time!!!!!!!!     

Viewing 4 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply