You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: T-SQL statements that are less than fully supported in Azure SQL Database.
2
+
title: T-SQL Differences Between SQL Server and Azure SQL Database
3
+
description: This article discusses the Transact-SQL (T-SQL) differences between an Azure SQL Database and SQL Server.
4
4
author: croblesm
5
5
ms.author: roblescarlos
6
-
ms.reviewer: wiassaf, mathoma
7
-
ms.date: 06/17/2021
6
+
ms.reviewer: wiassaf, mathoma, randolphwest
7
+
ms.date: 11/22/2024
8
8
ms.service: azure-sql-database
9
9
ms.subservice: migration
10
10
ms.topic: reference
@@ -15,50 +15,50 @@ ms.custom:
15
15
---
16
16
# T-SQL differences between SQL Server and Azure SQL Database
17
17
18
-
When [migrating your database](migrate-to-database-from-sql-server.md) from SQL Server to Azure SQL Database, you may discover that your SQL Server databases require some re-engineering before they can be migrated. This article provides guidance to assist you in both performing this re-engineering and understanding the underlying reasons why the re-engineering is necessary. To detect incompatibilities and migrate databases to Azure SQL Database, use [Data Migration Assistant (DMA)](/sql/dma/dma-overview).
18
+
When [migrating your database](migrate-to-database-from-sql-server.md) from SQL Server to Azure SQL Database, you might discover that your SQL Server databases require some re-engineering before they can be migrated. This article provides guidance to assist you in both performing this re-engineering and understanding the underlying reasons why the re-engineering is necessary. To detect incompatibilities and migrate databases to Azure SQL Database, use [Azure Data Migration Service](/azure/dms).
19
19
20
20
[!INCLUDE [entra-id](../includes/entra-id.md)]
21
21
22
22
## Overview
23
23
24
-
Most T-SQL features that applications use are fully supported in both Microsoft SQL Server and Azure SQL Database. For example, the core SQL components such as data types, operators, string, arithmetic, logical, and cursor functions work identically in SQL Server and SQL Database. There are, however, a few T-SQL differences in DDL (data definition language) and DML (data manipulation language) elements resulting in T-SQL statements and queries that are only partially supported (which we discuss later in this article).
24
+
Most Transact-SQL (T-SQL) features that applications use are fully supported in both Microsoft SQL Server and Azure SQL Database. For example, the core SQL components such as data types, operators, string, arithmetic, logical, and cursor functions work identically in SQL Server and SQL Database. There are, however, a few T-SQL differences in DDL (data definition language) and DML (data manipulation language) elements resulting in T-SQL statements and queries that are only partially supported (which we discuss later in this article).
25
25
26
-
In addition, there are some features and syntax that isn't supported at all because Azure SQL Database is designed to isolate features from dependencies on the system databases and the operating system. As such, most instance-level features are not supported in SQL Database. T-SQL statements and options aren't available if they configure instance-level options, operating system components, or specify file system configuration. When such capabilities are required, an appropriate alternative is often available in some other way from SQL Database or from another Azure feature or service.
26
+
In addition, there are some features and syntax that isn't supported at all because Azure SQL Database is designed to isolate features from dependencies on the system databases and the operating system. As such, most instance-level features aren't supported in SQL Database. T-SQL statements and options aren't available if they configure instance-level options, operating system components, or specify file system configuration. When such capabilities are required, an appropriate alternative is often available in some other way from SQL Database or from another Azure feature or service.
27
27
28
-
For example, high availability is built into Azure SQL Database. T-SQL statements related to availability groups are not supported by SQL Database, and the dynamic management views related to Always On Availability Groups are also not supported.
28
+
For example, high availability is built into Azure SQL Database. T-SQL statements related to availability groups aren't supported by SQL Database, and the dynamic management views related to Always On Availability Groups are also not supported.
29
29
30
-
For a list of the features that are supported and unsupported by SQL Database, see [Azure SQL Database feature comparison](features-comparison.md). This page supplements that article, and focuses on T-SQL statements.
30
+
For a list of the features that are supported and unsupported by SQL Database, see [Features comparison: Azure SQL Database and Azure SQL Managed Instance](features-comparison.md). This page supplements that article, and focuses on T-SQL statements.
31
31
32
32
## T-SQL syntax statements with partial differences
33
33
34
-
The core DDL statements are available, but DDL statement extensions related to unsupported features, such as file placement on disk, are not supported.
34
+
The core DDL statements are available, but DDL statement extensions related to unsupported features, such as file placement on disk, aren't supported.
35
35
36
-
- In SQL Server, `CREATE DATABASE` and `ALTER DATABASE` statements have over three dozen options. The statements include file placement, FILESTREAM, and service broker options that only apply to SQL Server. This may not matter if you create databases in SQL Database before you migrate, but if you're migrating T-SQL code that creates databases you should compare [CREATE DATABASE (Azure SQL Database)](/sql/t-sql/statements/create-database-transact-sql?view=azuresqldb-current&preserve-view=true) with the SQL Server syntax at [CREATE DATABASE (SQL Server T-SQL)](/sql/t-sql/statements/create-database-transact-sql?view=sql-server-ver15&preserve-view=true) to make sure all the options you use are supported. `CREATE DATABASE` for Azure SQL Database also has service objective and elastic pool options that apply only to SQL Database.
36
+
- In SQL Server, `CREATE DATABASE` and `ALTER DATABASE` statements have over three dozen options. The statements include file placement, FILESTREAM, and service broker options that only apply to SQL Server. This might not matter if you create databases in SQL Database before you migrate, but if you're migrating T-SQL code that creates databases you should compare [CREATE DATABASE (Azure SQL Database)](/sql/t-sql/statements/create-database-transact-sql?view=azuresqldb-current&preserve-view=true) with the SQL Server syntax at [CREATE DATABASE (SQL Server T-SQL)](/sql/t-sql/statements/create-database-transact-sql?view=sql-server-ver15&preserve-view=true) to make sure all the options you use are supported. `CREATE DATABASE` for Azure SQL Database also has service objective and elastic pool options that apply only to SQL Database.
37
37
- The `CREATE TABLE` and `ALTER TABLE` statements have `FILETABLE` and `FILESTREAM` options that can't be used on SQL Database because these features aren't supported.
38
-
-`CREATE LOGIN` and `ALTER LOGIN` statements are supported, but do not offer all options available in SQL Server. To make your database more portable, SQL Database encourages using contained database users instead of logins whenever possible. For more information, see [CREATE LOGIN](/sql/t-sql/statements/create-login-transact-sql?view=azuresqldb-current&preserve-view=true) and [ALTER LOGIN](/sql/t-sql/statements/alter-login-transact-sql?view=azuresqldb-current&preserve-view=true) and [Manage logins and users](logins-create-manage.md).
38
+
-`CREATE LOGIN` and `ALTER LOGIN` statements are supported, but don't offer all options available in SQL Server. To make your database more portable, SQL Database encourages using contained database users instead of logins whenever possible. For more information, see [CREATE LOGIN](/sql/t-sql/statements/create-login-transact-sql?view=azuresqldb-current&preserve-view=true), [ALTER LOGIN](/sql/t-sql/statements/alter-login-transact-sql?view=azuresqldb-current&preserve-view=true), and [Authorize database access to SQL Database, SQL Managed Instance, and Azure Synapse Analytics](logins-create-manage.md).
39
39
40
40
## T-SQL syntax not supported in Azure SQL Database
41
41
42
-
In addition to T-SQL statements related to the unsupported features described in [Azure SQL Database feature comparison](features-comparison.md), the following statements and groups of statements aren't supported. As such, if your database to be migrated is using any of the following features, re-engineer your application to eliminate these T-SQL features and statements.
42
+
In addition to T-SQL statements related to the unsupported features described in [Features comparison: Azure SQL Database and Azure SQL Managed Instance](features-comparison.md), the following statements and groups of statements aren't supported. As such, if your database to be migrated is using any of the following features, re-engineer your application to eliminate these T-SQL features and statements.
43
43
44
44
- Collation of system objects.
45
-
- Connection related: Endpoint statements. SQL Database doesn't support Windows authentication, but does support Microsoft Entra authentication. This includes authentication of Active Directory principals federated with Microsoft Entra ID ([formerly Azure Active Directory](/entra/fundamentals/new-name)). For more information, see [Connecting to SQL Database or Azure Azure Synapse Analytics By Using Microsoft Entra authentication](authentication-aad-overview.md).
45
+
- Connection related: Endpoint statements. SQL Database doesn't support Windows authentication, but does support Microsoft Entra authentication. This includes authentication of Active Directory principals federated with [Microsoft Entra ID](/entra/fundamentals/new-name). For more information, see [Microsoft Entra authentication for Azure SQL](authentication-aad-overview.md).
46
46
- Cross-database and cross-instance queries using three or four part names. Three part names referencing the `tempdb` database and the current database are supported. [Elastic query](elastic-query-overview.md) supports read-only references to tables in other MSSQL databases.
47
47
- Cross database ownership chaining and the `TRUSTWORTHY` database property.
48
48
-`EXECUTE AS LOGIN`. Use `EXECUTE AS USER` instead.
49
-
- Extensible key management (EKM) for encryption keys. Transparent Data Encryption (TDE) [customer-managed keys](transparent-data-encryption-byok-overview.md) and Always Encrypted [column master keys](always-encrypted-azure-key-vault-configure.md)may be stored in Azure Key Vault.
49
+
- Extensible key management (EKM) for encryption keys. Transparent data encryption (TDE) [customer-managed keys](transparent-data-encryption-byok-overview.md) and Always Encrypted [column master keys](always-encrypted-azure-key-vault-configure.md)can be stored in Azure Key Vault.
- File properties: Syntax related to database file name, placement, size, and other file properties automatically managed by SQL Database.
52
52
- High availability: Syntax related to high availability and database recovery, which are managed by SQL Database. This includes syntax for backup, restore, Always On, database mirroring, log shipping, recovery models.
53
-
- Syntax related to snapshot, transactional, and merge replication, which is not available in SQL Database. [Replication subscriptions](replication-to-sql-database.md) are supported.
53
+
- Syntax related to snapshot, transactional, and merge replication, which isn't available in SQL Database. [Replication subscriptions](replication-to-sql-database.md) are supported.
- Instance configuration: Syntax related to server memory, worker threads, CPU affinity, trace flags. Use service tiers and compute sizes instead.
56
56
-`KILL STATS JOB`.
57
57
-`OPENQUERY`, `OPENDATASOURCE`, and four-part names.
58
-
- .NET Framework: CLR integration
58
+
- .NET Framework: common language runtime (CLR) integration
59
59
- Semantic search
60
60
- Server credentials: Use [database scoped credentials](/sql/t-sql/statements/create-database-scoped-credential-transact-sql) instead.
61
-
- Server-level permissions: `GRANT`, `REVOKE`, and `DENY` of server level permissions are not supported. Some server-level permissions are replaced by database-level permissions, or granted implicitly by built-in server roles. Some server-level DMVs and catalog views have similar database-level views.
61
+
- Server-level permissions: `GRANT`, `REVOKE`, and `DENY` of server level permissions aren't supported. Some server-level permissions are replaced by database-level permissions, or granted implicitly by built-in server roles. Some server-level DMVs and catalog views have similar database-level views.
62
62
-`SET REMOTE_PROC_TRANSACTIONS`
63
63
-`SHUTDOWN`
64
64
-`sp_addmessage`
@@ -75,16 +75,15 @@ In addition to T-SQL statements related to the unsupported features described in
75
75
76
76
## Full T-SQL reference
77
77
78
-
For more information about T-SQL grammar, usage, and examples, see [T-SQL Reference (Database Engine)](/sql/t-sql/language-reference).
78
+
For more information about T-SQL grammar, usage, and examples, see [Transact-SQL reference (Database Engine)](/sql/t-sql/language-reference).
79
79
80
80
### About the "Applies to" tags
81
81
82
-
The T-SQL reference includes articles related to all recent SQL Server versions. Below the article title there's an icon bar, listing MSSQL platforms, and indicating applicability. For example, availability groups were introduced in SQL Server 2012. The [CREATE AVAILABILITY GROUP](/sql/t-sql/statements/create-availability-group-transact-sql) article indicates that the statement applies to **SQL Server (starting with 2012)**. The statement doesn't apply to SQL Server 2008, SQL Server 2008 R2, Azure SQL Database, Azure Azure Synapse Analytics, or Parallel Data Warehouse.
82
+
The T-SQL reference includes articles related to all recent SQL Server versions. Below the article title there's an icon bar, listing MSSQL platforms, and indicating applicability. For example, availability groups were introduced in SQL Server 2012. The [CREATE AVAILABILITY GROUP](/sql/t-sql/statements/create-availability-group-transact-sql) article indicates that the statement applies to **SQL Server (starting with 2012)**. The statement doesn't apply to SQL Server 2008, SQL Server 2008 R2, Azure SQL Database, Azure Synapse Analytics, or Parallel Data Warehouse.
83
83
84
84
In some cases, the general subject of an article can be used in a product, but there are minor differences between products. The differences are indicated at midpoints in the article as appropriate. For example, the `CREATE TRIGGER` article is available in SQL Database. But the `ALL SERVER` option for server-level triggers, indicates that server-level triggers can't be used in SQL Database. Use database-level triggers instead.
85
85
86
-
## Next steps
86
+
## Related content
87
87
88
-
For a list of the features that are supported and unsupported by SQL Database, see [Azure SQL Database feature comparison](features-comparison.md).
89
-
90
-
To detect compatibility issues in your SQL Server databases before migrating to Azure SQL Database, and to migrate your databases, use [Data Migration Assistant (DMA)](/sql/dma/dma-overview).
88
+
-[Features comparison: Azure SQL Database and Azure SQL Managed Instance](features-comparison.md)
89
+
-[Overview of Data Migration Assistant](/sql/dma/dma-overview)
0 commit comments