• I did not mean to do deletes, but to do a switch out, followed by loading directly into the table.

    Jeff suggested two staging tables, one for switching out and another for switching in. First, you truncate both staging tables. Second you populate the switch-in staging table. At this point, all you need to do is to switch out from the partitioned table into switch-out staging table and immediately follow by switching in from the switch-in staging table into the partitioned table. As Jeff indicated, this will give you only a fraction of a second of down time.

    A third option with zero downtime is to create your partitioned table with extra partitions. You simply need a small table-of-contents (TOC) table that has as many rows as there are partitions in the partitioned table. Each row contains the partition ID, the tenant name and a status column. The status could be Available, Loading, Unloading and Active. For sake of example, suppose you have ten tenants and 11 partitions. The TOC table will contain 10 rows in Active status, one for each tenant, and one row with status of Available.

    When you want to load data for a tenant, you update the row with status of Available to set the status to Loading and set the tenant name. Once you are done loading the data, you simply update the TOC table to set the status of the Active row to Unloading and the status of the Loading row to Active. Queries will immediately use the new partition, as that is the one with Active status. I would suggest you create a scalar-valued function that takes as input the tenant name. The function will query the TOC for the tenant name with status of Active and return the partition ID. At this point you have as much time as you want to switch-out the data from the partitioned now marked as Unloading and set the TOC of this partition to Available.

    If you have many tenants and are concerned with concurrency of loading/unloading data for different tenants, you may create your partitioned table with extra partitions. For even greater flexibility, keep in mind that your staging table can also be partitioned and you can switch out from a partition in the main partitioned table into the same partition of staging table.