if object_id(N'dbo.tr_UserInfo_Delete') is null and exists (select * from sys.tables where object_id = object_id(N'dbo.UserInfo'))
begin
    exec ('create trigger dbo.tr_UserInfo_Delete
on dbo.UserInfo
for delete
as 
begin
    set nocount on

    insert into dbo.UserInfoHistory (HistoryType, UserInfoID, ModifiedDate, ModifiedUserName, ModifiedLoggedUserName, Data)
    select ''D'', ID, getdate(), ModifiedUserName, ModifiedLoggedUserName, Data
    from deleted
end');
end