DECLARE @user_id UNIQUEIDENTIFIER;
DECLARE @changeset_id INT;
SELECT TOP 1 @user_id = tu.userid
FROM vclib.t_users tu 
JOIN vclib.t_identity ti ON tu.[Identity] = ti.IdentityID
WHERE ti.identityname = 'Administrator';
IF @user_id IS NULL
BEGIN
    SELECT TOP 1 @user_id = userid
    FROM vclib.t_users;
END;
EXEC @changeset_id = dbo.sp_GenerateIdForEntity @EntName = 'VCLib.CHANGESET', @FieldName = 'PrimaryKey', @count = 1;
INSERT INTO vclib.t_changesets (id, timestamp, userid)
VALUES (@changeset_id, GETDATE(), @user_id);
EXEC dbo.sp_CopyDataToHistory 'T_V019_VMP_METHOD', 'T_V019_VMP_METHOD_HISTORY', @changeset_id;