Remove-AzureSqlDatabase
Deletes an Azure SQL Database.
Note
The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.
The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.
Syntax
Remove-AzureSqlDatabase
-ConnectionContext <IServerDataServiceContext>
-DatabaseName <String>
[-Force]
[-Profile <AzureSMProfile>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzureSqlDatabase
-ConnectionContext <IServerDataServiceContext>
-Database <Database>
[-Force]
[-Profile <AzureSMProfile>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzureSqlDatabase
-ServerName <String>
-DatabaseName <String>
[-Force]
[-Profile <AzureSMProfile>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzureSqlDatabase
-ServerName <String>
-Database <Database>
[-Force]
[-Profile <AzureSMProfile>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Remove-AzureSqlDatabase cmdlet deletes an Azure SQL Database by server connection context or server name. You can create an Azure SQL Database server connection context using the New-AzureSqlDatabaseServerContext cmdlet, and then use it with this cmdlet.
When you delete a database by specifying an Azure SQL Database server name, the Remove-AzureSqlDatabase cmdlet uses the name and the current Azure subscription information to perform the operation.
Examples
Example 1: Remove a database
PS C:\> Remove-AzureSqlDatabase -ConnectionContext $Context -DatabaseName "Database01"
This command removes the database named Database01 from the Azure SQL Database server connection context $Context.
Example 2: Remove a database by using a server name
PS C:\> Remove-AzureSqlDatabase -ServerName "lpqd0zbr8y" -DatabaseName "Database01"
This command removes the database named Database01 from the Azure SQL Database server named lpqd0zbr8y.
Example 3: Remove a database by using the pipeline
PS C:\> $Database01 | Remove-AzureSqlDatabase -ConnectionContext $Context
PS C:\> $Database01 | Remove-AzureSqlDatabase -ServerName "lpqd0zbr8y"
This example demonstrates the alternative method of passing the database object through the pipeline.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ConnectionContext
Specifies the connection context of a server from which this cmdlet removes a database.
Type: | IServerDataServiceContext |
Aliases: | Context |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Database
Specifies an object that represents the database that this cmdlet removes.
Type: | Database |
Aliases: | InputObject |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DatabaseName
Specifies the name of the database that this cmdlet removes.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Force
Allows the action to complete without prompting the user for confirmation.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Profile
Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.
Type: | AzureSMProfile |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ServerName
Specifies the name of the server on which this cmdlet deletes the database.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.Database
Notes
- Because of the severity of the operation, by default, this cmdlet prompts you for confirmation. To skip confirmation, specify the Force parameter.