---
title: Snowflake - Load data - Linked projects
description: Load two Snowflake projects in order when one uses the other as a linked project, such as a Data Vault project on a Stage Files project.
---

[Skip to content](https://knowledge.bigenius-x.com/snowflake-load-data-linked-projects#main-content)

[Contact us](https://knowledge.bigenius-x.com/kb-tickets/new?hsLang=en) [Go to Customer Portal](https://knowledge.bigenius-x.com/customer-portal?hsLang=en)

[![TRI\_Logo\_biGENIUS\_2020\_RGB\_s](https://knowledge.bigenius-x.com/hs-fs/hubfs/Marketing/TRI_Logo_biGENIUS_2020_RGB_s.png?width=150&height=42&name=TRI_Logo_biGENIUS_2020_RGB_s.png)](https://www.bigenius-x.com/)

Open main navigation

Close main navigation

- [Contact us](https://knowledge.bigenius-x.com/kb-tickets/new)
- [Go to Customer Portal](https://knowledge.bigenius-x.com/customer-portal)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [biGENIUS-X Knowledge Base](https://knowledge.bigenius-x.com/?hsLang=en)
2. [Generators](https://knowledge.bigenius-x.com/generators?hsLang=en)
3. [Load data with a native load control](https://knowledge.bigenius-x.com/generators?hsLang=en#load-data-with-a-native-load-control)

# Snowflake - Load data - Linked projects

**Applies to**  
Platform: Snowflake

Load two Snowflake projects in order when one uses the other as a linked project, such as a Data Vault project on a Stage Files project. A stored procedure starts the task graph of the first project, waits until it has succeeded and then starts the task graph of the second project. Afterwards the second load has started only after the first has succeeded, never after a failed first load.

`EXECUTE TASK` only starts a task graph and returns at once, so a fixed wait between two `EXECUTE TASK` statements does not ensure the order. The procedure reads the state of the first graph instead.

### Prerequisites

- Both projects use [LoadControl Options](https://knowledge.bigenius-x.com/loadcontrol-options-project?hsLang=en) `Depending Tasks` and are [deployed](https://knowledge.bigenius-x.com/snowflake-deployment-2.0?hsLang=en), each into its own load control schema.
  
  Deploying a project with Generate Drop Load Control Schema selected drops the load control schema with the tasks of every project in it. Give each project its own load control schema.
- A role that owns the tasks of both projects and has the account privilege `EXECUTE TASK`.

### Load the projects in order

1. In each project, run the blocks Enable all tasks and To manually execute the root task directly of `snowflake_depending_tasks_helper.sql`, without the last statement `EXECUTE TASK`, as described in [Snowflake - Load data - Native Load Control](https://knowledge.bigenius-x.com/snowflake-load-data-native-load-control-2.0?hsLang=en#load-once). The child tasks are then resumed. `EXECUTE TASK` skips suspended child tasks.
2. Create the procedure in a schema of your choice, `<database>.<schema>`:
   
   ```
   CREATE OR REPLACE PROCEDURE <database>.<schema>.RUN_AFTER_SUCCESS(
     FIRST_ROOT_TASK VARCHAR,
     NEXT_ROOT_TASK VARCHAR, TIMEOUT_SECONDS INTEGER)
   RETURNS VARCHAR
   LANGUAGE SQL
   EXECUTE AS CALLER
   AS
   $$
   DECLARE
       start_time TIMESTAMP_LTZ;
       run_state VARCHAR;
       waited INTEGER DEFAULT 0;
       first_failed EXCEPTION (-20101, 'The first task graph did not succeed. The next task graph was not started.');
       first_timeout EXCEPTION (-20102, 'The first task graph did not finish in time. The next task graph was not started.');
   BEGIN
       start_time := CURRENT_TIMESTAMP();
       EXECUTE IMMEDIATE 'EXECUTE TASK ' || FIRST_ROOT_TASK;
       LOOP
           CALL SYSTEM$WAIT(10);
           waited := waited + 10;
           run_state := NULL;
           SELECT MAX(STATE) INTO :run_state
           FROM TABLE(INFORMATION_SCHEMA.COMPLETE_TASK_GRAPHS())
           WHERE DATABASE_NAME = SPLIT_PART(:FIRST_ROOT_TASK, '.', 1)
             AND SCHEMA_NAME = SPLIT_PART(:FIRST_ROOT_TASK, '.', 2)
             AND ROOT_TASK_NAME = SPLIT_PART(:FIRST_ROOT_TASK, '.', 3)
             AND SCHEDULED_TIME >= :start_time;
           IF (run_state = 'SUCCEEDED') THEN
               EXECUTE IMMEDIATE 'EXECUTE TASK ' || NEXT_ROOT_TASK;
               RETURN 'First task graph succeeded after about ' || waited
                 || ' seconds; next task graph started.';
           ELSEIF (run_state IN ('FAILED', 'CANCELLED')) THEN
               RAISE first_failed;
           ELSEIF (waited >= TIMEOUT_SECONDS) THEN
               RAISE first_timeout;
           END IF;
       END LOOP;
   END;
   $$;
   ```
3. Run it with the root tasks of both projects and a timeout in seconds. The procedure reads `INFORMATION_SCHEMA` of the current database, so the session needs one:
   
   ```
   USE DATABASE <database>;
   CALL <database>.<schema>.RUN_AFTER_SUCCESS(
     '<database A>.<load control schema A>.LOAD_<PROJECT A>_ROOT_TASK',
     '<database B>.<load control schema B>.LOAD_<PROJECT B>_ROOT_TASK',
     <timeout in seconds>);
   ```
   
    Write the task names fully qualified and in upper case. The procedure splits them at the dots, so quoted names that contain a dot are not supported.
4. To start the load as a task instead, create a task that calls the procedure and run it:
   
   ```
   CREATE OR REPLACE TASK LOAD_ALL_PROJECTS_TASK
       WAREHOUSE = <warehouse>
   AS
       CALL <database>.<schema>.RUN_AFTER_SUCCESS(
         '<root task A>', '<root task B>', <timeout in seconds>);
   
   EXECUTE TASK LOAD_ALL_PROJECTS_TASK;
   ```
   
    A task run also ends at the task timeout of Snowflake, 60 minutes by default.

Every 10 seconds the procedure reads the run of the first graph that started after the call. When it shows `SUCCEEDED`, the procedure starts the second graph and returns. A timeout does not stop the first graph.

### Check the result

The call returns `First task graph succeeded after about <number> seconds; next task graph started.` Then check both graphs:

```
SELECT ROOT_TASK_NAME, STATE, SCHEDULED_FROM, SCHEDULED_TIME,
       COMPLETED_TIME
FROM TABLE(INFORMATION_SCHEMA.COMPLETE_TASK_GRAPHS())
ORDER BY COMPLETED_TIME;
```

Both root tasks show `SUCCEEDED` with `SCHEDULED_FROM` `EXECUTE TASK`. The second graph has a `SCHEDULED_TIME` after the `COMPLETED_TIME` of the first.

### Example

The first graph has a child task that waits 90 seconds, and the second graph writes one row. The procedure was called with a timeout of 600 seconds. The first graph was scheduled at 23:12:12 and completed at 23:13:46. The second graph was scheduled at 23:13:47, one second later. When the child task of the first graph failed, the call ended with error -20101, and the second graph wrote no row.

### Failure symptoms and recovery

#### The first task graph did not succeed

Message: `-20101` with `The first task graph did not succeed. The next task graph was not started.`  
Cause: The first graph ended with `FAILED` or `CANCELLED`.  
Fix: Read `FIRST_ERROR_TASK_NAME` and `FIRST_ERROR_MESSAGE` of the run in `COMPLETE_TASK_GRAPHS`, correct the cause and call the procedure again.

#### The first task graph did not finish in time

Message: `-20102` with `The first task graph did not finish in time. The next task graph was not started.`  
Cause: The first graph ran longer than the timeout. It keeps running.  
Fix: Wait until it has ended and check its state. Call the procedure again with a longer timeout, or start the second graph with `EXECUTE TASK` after the first has succeeded.

#### A task graph has more than one root task

Message: `091419 (22000): Unreachable task <task name> found. The graph has more than one root task (one without predecessors).`  
Cause: Two projects were deployed into the same load control schema and have model objects with the same name. Their tasks replaced each other.  
Fix: Give each project its own load control schema in the placeholder values and deploy both projects again.

For failures in other steps, see [Troubleshoot generation, deployment and load failures](https://knowledge.bigenius-x.com/troubleshoot-generation-deployment-and-load-failures?hsLang=en).

### Related articles

- Previous: [Snowflake - Deployment](https://knowledge.bigenius-x.com/snowflake-deployment-2.0?hsLang=en), [Snowflake - Load data - Native Load Control](https://knowledge.bigenius-x.com/snowflake-load-data-native-load-control-2.0?hsLang=en)
- Reference: [Snowflake - Placeholder values](https://knowledge.bigenius-x.com/snowflake-placeholder-values-2.0?hsLang=en), [LoadControl Options (Project)](https://knowledge.bigenius-x.com/loadcontrol-options-project?hsLang=en), [Deployment Options (Project)](https://knowledge.bigenius-x.com/deployment-options-project?hsLang=en)
- See also: [Manage Linked Projects](https://knowledge.bigenius-x.com/manage-linked-projects?hsLang=en), [Use Linked Projects](https://knowledge.bigenius-x.com/use-linked-projects?hsLang=en), [Snowflake - Target environment](https://knowledge.bigenius-x.com/snowflake-target-environment?hsLang=en)

- [Getting started](https://knowledge.bigenius-x.com/getting-started?hsLang=en#main-content)

    - [Guidelines](https://knowledge.bigenius-x.com/getting-started?hsLang=en#guidelines)
    - [Start working](https://knowledge.bigenius-x.com/getting-started?hsLang=en#start-working)
    - [Account](https://knowledge.bigenius-x.com/getting-started?hsLang=en#account)
- [General overview](https://knowledge.bigenius-x.com/general-overview?hsLang=en)
- [Artificial Intelligence](https://knowledge.bigenius-x.com/artificial-intelligence?hsLang=en)
- [Application Modules](https://knowledge.bigenius-x.com/application-modules?hsLang=en#main-content)

    - [Administration](https://knowledge.bigenius-x.com/application-modules?hsLang=en#administration)
    - [Solutions](https://knowledge.bigenius-x.com/application-modules?hsLang=en#solutions)
    - [Global Features](https://knowledge.bigenius-x.com/application-modules?hsLang=en#global-features)
    - [Projects](https://knowledge.bigenius-x.com/application-modules?hsLang=en#projects)
    - [Branches](https://knowledge.bigenius-x.com/application-modules?hsLang=en#branches)
    - [Data Connections](https://knowledge.bigenius-x.com/application-modules?hsLang=en#data-connections)
    - [Dataflow Modeling - Overview](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-overview)
    - [Dataflow Modeling - Wizard Steps](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-wizard-steps)
    - [Dataflow Modeling - Terms](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-terms)
    - [Dataflow Modeling - Term Mapping](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-term-mapping)
    - [Dataflow Modeling - Relationships](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-relationships)
    - [Dataflow Modeling - Data Quality](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-data-quality)
    - [Dataflow Modeling - Indexes](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-indexes)
    - [Relationship Modeling](https://knowledge.bigenius-x.com/application-modules?hsLang=en#relationship-modeling)
    - [Generate Artifacts](https://knowledge.bigenius-x.com/application-modules?hsLang=en#generate-artifacts)
    - [Project Settings](https://knowledge.bigenius-x.com/application-modules?hsLang=en#project-settings)
    - [Data Marketplace](https://knowledge.bigenius-x.com/application-modules?hsLang=en#data-marketplace)
- [Generators](https://knowledge.bigenius-x.com/generators?hsLang=en#main-content)

    - [Fabric Warehouse](https://knowledge.bigenius-x.com/generators?hsLang=en#fabric-warehouse)
    - [Fabric Lakehouse](https://knowledge.bigenius-x.com/generators?hsLang=en#fabric-lakehouse)
    - [Databricks](https://knowledge.bigenius-x.com/generators?hsLang=en#databricks)
    - [Snowflake](https://knowledge.bigenius-x.com/generators?hsLang=en#snowflake)
    - [Microsoft SQL Server](https://knowledge.bigenius-x.com/generators?hsLang=en#microsoft-sql-server)
    - [Oracle](https://knowledge.bigenius-x.com/generators?hsLang=en#oracle)
    - [Artifacts](https://knowledge.bigenius-x.com/generators?hsLang=en#artifacts)
    - [Replace Placeholders](https://knowledge.bigenius-x.com/generators?hsLang=en#replace-placeholders)
    - [Target solution environment](https://knowledge.bigenius-x.com/generators?hsLang=en#target-solution-environment)
    - [Deployment](https://knowledge.bigenius-x.com/generators?hsLang=en#deployment)
    - [Deployment with an Azuze DevOps pipeline](https://knowledge.bigenius-x.com/generators?hsLang=en#deployment-with-an-azuze-devops-pipeline)
    - [Delta Deployment](https://knowledge.bigenius-x.com/generators?hsLang=en#delta-deployment)
    - [Load control environment](https://knowledge.bigenius-x.com/generators?hsLang=en#load-control-environment)
    - [Load data with a native load control](https://knowledge.bigenius-x.com/generators?hsLang=en#load-data-with-a-native-load-control)
    - [Load data with Apache Airflow](https://knowledge.bigenius-x.com/generators?hsLang=en#load-data-with-apache-airflow)
    - [Model Object Type](https://knowledge.bigenius-x.com/generators?hsLang=en#model-object-type)
    - [Properties](https://knowledge.bigenius-x.com/generators?hsLang=en#properties)
    - [Default Terms](https://knowledge.bigenius-x.com/generators?hsLang=en#default-terms)
- [Discovery application](https://knowledge.bigenius-x.com/discovery-application?hsLang=en#main-content)

    - [Discovery configurations](https://knowledge.bigenius-x.com/discovery-application?hsLang=en#discovery-configurations)
- [Best practices](https://knowledge.bigenius-x.com/best-practices?hsLang=en#main-content)

    - [Modeling Approaches](https://knowledge.bigenius-x.com/best-practices?hsLang=en#modeling-approaches)
    - [Use Cases](https://knowledge.bigenius-x.com/best-practices?hsLang=en#use-cases)
    - [Business Rules](https://knowledge.bigenius-x.com/best-practices?hsLang=en#business-rules)
    - [Data Quality Rules](https://knowledge.bigenius-x.com/best-practices?hsLang=en#data-quality-rules)
- [FAQs](https://knowledge.bigenius-x.com/faqs?hsLang=en)
- [Product Release Notes](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#main-content)

    - [SaaS Application](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#saas-application)
    - [Discovery application](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#discovery-application)
    - [Generators](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#generators)
- [Legal Documents](https://knowledge.bigenius-x.com/legal-documents?hsLang=en#main-content)

    - [Current legal docs](https://knowledge.bigenius-x.com/legal-documents?hsLang=en#current-legal-docs)
    - [Software Product and Limits](https://knowledge.bigenius-x.com/legal-documents?hsLang=en#software-product-and-limits)

- [Contact us](https://knowledge.bigenius-x.com/kb-tickets/new?hsLang=en)
- [Customer Portal](https://knowledge.bigenius-x.com/customer-portal)
- [Sign in](https://knowledge.bigenius-x.com/_hcms/mem/login)

[![biGENIUS logo](https://knowledge.bigenius-x.com/hubfs/TRI_Logo_biGENIUS_2020_RGB-1.svg "biGENIUS logo")](https://www.bigenius-x.com)

<https://www.linkedin.com/company/bigenius> <https://www.youtube.com/@biGENIUS_DWA>

All rights reserved © 2025, biGENIUS AG