Edit

Share via


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

ByNameWithConnectionContext

Remove-AzureSqlDatabase
    -ConnectionContext <IServerDataServiceContext>
    -DatabaseName <String>
    [-Force]
    [-Profile <AzureSMProfile>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByObjectWithConnectionContext

Remove-AzureSqlDatabase
    -ConnectionContext <IServerDataServiceContext>
    -Database <Database>
    [-Force]
    [-Profile <AzureSMProfile>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByNameWithServerName

Remove-AzureSqlDatabase
    -ServerName <String>
    -DatabaseName <String>
    [-Force]
    [-Profile <AzureSMProfile>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByObjectWithServerName

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.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ConnectionContext

Specifies the connection context of a server from which this cmdlet removes a database.

Parameter properties

Type:IServerDataServiceContext
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Context

Parameter sets

ByNameWithConnectionContext
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByObjectWithConnectionContext
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Database

Specifies an object that represents the database that this cmdlet removes.

Parameter properties

Type:Database
Default value:None
Supports wildcards:False
DontShow:False
Aliases:InputObject

Parameter sets

ByObjectWithConnectionContext
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False
ByObjectWithServerName
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-DatabaseName

Specifies the name of the database that this cmdlet removes.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByNameWithConnectionContext
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByNameWithServerName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Allows the action to complete without prompting the user for confirmation.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:AzureSMProfile
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ServerName

Specifies the name of the server on which this cmdlet deletes the database.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByNameWithServerName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
ByObjectWithServerName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

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.