CREATE TRIGGER connection_limit_trigger
ON ALL SERVER
FOR LOGON
AS
BEGIN
declare @ip nvarchar(max)
declare @loginName nvarchar(max)
SELECT @ip=EVENTDATA().value
('(/EVENT_INSTANCE/ClientHost)[1]','nvarchar(max)')
SELECT @loginName=EVENTDATA().value
('(/EVENT_INSTANCE/LoginName)[1]','nvarchar(max)')
if @loginName='sa' and @ip<>'127.0.0.1'--replaced with your ip
rollback
END;
go
-- drop trigger trigger_name