• Yes, it's possible. You have to use dynamic SQL to accomplish it. Below I quickly created a small stored procedure that does the trick. I didn't include any error handling, so alter it to your needs before taking it in production.

    create procedure toggle_login (@login_name nvarchar(125), @set_enable bit)

    as

    begin

    declare @sql_command nvarchar(500)

    set @sql_command = 'ALTER LOGIN [' + @login_name + '] ' + case when @set_enable = 1 then 'ENABLE' else 'DISABLE' end

    print @sql_command

    exec sp_executesql @sql_command

    end

    -- usage of above stored procedure

    exec toggle_login 'test', true

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **