Clear D365BacpacTableData - FH-Inway/d365fo.tools GitHub Wiki
Clear out data for a table inside the bacpac/dacpac or zip file
Clear-D365BacpacTableData -Path <String> -Table <String[]> -OutputPath <String> [<CommonParameters>]
Clear-D365BacpacTableData -Path <String> -Table <String[]> [-ClearFromSource] [<CommonParameters>]
Remove all data for a table inside a bacpac/dacpac or zip file, before restoring it into your SQL Server / Azure SQL DB
It will open the file as a zip archive, locate the desired table and remove the data that otherwise would have been loaded
The default behavior is that you get a copy of the file, where the desired data is removed
Clear-D365BacpacTableData -Path "C:\Temp\AxDB.bacpac" -Table "BATCHJOBHISTORY" -OutputPath "C:\Temp\AXBD_Cleaned.bacpac"
This will remove the data from the BatchJobHistory table from inside the bacpac file.
It uses "C:\Temp\AxDB.bacpac" as the Path for the bacpac file. It uses "BATCHJOBHISTORY" as the Table to delete data from. It uses "C:\Temp\AXBD_Cleaned.bacpac" as the OutputPath to where it will store the updated bacpac file.
Clear-D365BacpacTableData -Path "C:\Temp\AxDB.bacpac" -Table "dbo.BATCHHISTORY","BATCHJOBHISTORY" -OutputPath "C:\Temp\AXBD_Cleaned.bacpac"
This will remove the data from the dbo.BatchHistory and BatchJobHistory table from inside the bacpac file.
It uses "C:\Temp\AxDB.bacpac" as the Path for the bacpac file. It uses "dbo.BATCHHISTORY","BATCHJOBHISTORY" as the Table to delete data from. It uses "C:\Temp\AXBD_Cleaned.bacpac" as the OutputPath to where it will store the updated bacpac file.
Clear-D365BacpacTableData -Path "C:\Temp\AxDB.bacpac" -Table "dbo.BATCHHISTORY","BATCHJOBHISTORY" -ClearFromSource
This will remove the data from the dbo.BatchHistory and BatchJobHistory table from inside the bacpac file.
It uses "C:\Temp\AxDB.bacpac" as the Path for the bacpac file. It uses "dbo.BATCHHISTORY","BATCHJOBHISTORY" as the Table to delete data from.
Caution: It will remove from the source "C:\Temp\AxDB.bacpac" directly. So if the original file is important for further processing, please consider the risks carefully.
Clear-D365BacpacTableData -Path "C:\Temp\AxDB.bacpac" -Table "CustomTableNameThatDoesNotExists","BATCHJOBHISTORY" -OutputPath "C:\Temp\AXBD_Cleaned.bacpac" -ErrorAction SilentlyContinue
This will remove the data from the BatchJobHistory table from inside the bacpac file.
It uses "C:\Temp\AxDB.bacpac" as the Path for the bacpac file. It uses "CustomTableNameThatDoesNotExists","BATCHJOBHISTORY" as the Table to delete data from. It respects the respects the ErrorAction "SilentlyContinue", and will continue removing tables from the bacpac file, even when some tables are missing. It uses "C:\Temp\AXBD_Cleaned.bacpac" as the OutputPath to where it will store the updated bacpac file.
Path to the bacpac/dacpac or zip file that you want to work against
Type: String
Parameter Sets: (All)
Aliases: BacpacFile, File
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Name of the table that you want to delete the data for
Supports an array of table names
If a schema name isn't supplied as part of the table name, the cmdlet will prefix it with "dbo."
Supports wildcard searching e.g. "Sales*" will delete all "dbo.Sales*" tables in the bacpac file
Type: String[]
Parameter Sets: (All)
Aliases: TableName
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Path to where you want the updated bacpac/dacpac or zip file to be saved
Type: String
Parameter Sets: Copy
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Instruct the cmdlet to delete tables directly from the source file
It will save disk space and time, because it doesn't have to create a copy of the bacpac file, before deleting tables from it
Type: SwitchParameter
Parameter Sets: Keep
Aliases:
Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Tags: Bacpac, Servicing, Data, Deletion, SqlPackage
Author: Mötz Jensen (@Splaxi)