SQL Azure supports T-SQL. Chances are, you're already familiar with SQL Server T-SQL syntax if you're reading this book. However, the book includes this appendix because not everything you know and love about SQL Server is supported yet in SQL Azure. This appendix provides a quick reference to the syntax that is currently supported in SQL Azure as of Service Update 4.
You can find a complete list and reference that describes T-SQL supported in SQL Azure at http://msdn.microsoft.com/en-us/library/ee336281.aspx
.
Table B-1 lists the supported T-SQL statements that you can use in SQL Azure. These statements can be used as exactly as you currently know them without any limitations.
Table B.1. Fully Supported T-SQL Statements
|
|
|
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Table B-2 lists the partially supported T-SQL statements that you can use in SQL Azure. "Partially supported" means you can use these statements, but with some variations (or limitations) to the syntax. Examples are provided following the table.
Table B.2. Partially Supported T-SQL Statements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For example, when you're creating or altering a stored procedure in SQL Azure, the FOR REPLICATION
and ENCRYPTION
options aren't supported. Thus, the following isn't valid:
CREATE PROCEDURE GetUsers WITH ENCRYPTION FOR REPLICATION AS
SET NOCOUNT ON; SELECT Title, Name, Intro FROM Users GO
However, the following is valid:
CREATE PROCEDURE GetUsers WITH RECOMPILE, EXECUTE AS CALLER AS SET NOCOUNT ON; SELECT Title, Name, Intro FROM Users GO
The CREATE/ALTER
table syntax for SQL Azure is a bit trickier, because there are several unsupported options:
ON keyword {
partition_schema
|
filegroup
}
(such as ON PRIMARY
)
TEXTIMAGE_ON
FILESTREAM_ON
<column_definition>
FILESTREAM
NOT FOR REPLICATION
ROWGUIDCOL
SPARSE
<data type>
CONTENT
DOCUMENT
xml_schema_collection
<column_constraint>
FILLFACTOR
ON
NOT FOR REPLICATION
<column_set_definition>
<table_constraint>
<index_option>
PAD_INDEX
FILLFACTOR
ON PARTITIONS
DATA_COMPRESSION
ALLOW_ROW_LOCKS
ALLOW_PAGE_LOCKS
<table_option>
Although this list may give the impression of much missing functionality, keep in mind that most of the items in the list are there due to the fact that they're operating-system or hardware related. As an example, the following CREATE TABLE
statement is invalid:
CREATE TABLE [dbo].[Users]( [ID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, [Name] [nvarchar](50) NULL, [NTUserName] [nvarchar](128) NULL, [Domain] [nvarchar](50) NOT NULL, [Intro] [nvarchar](100) NULL, [Title] [nvarchar](50) NOT NULL, [State] [nvarchar](10) NOT NULL, [Country] [nvarchar](100) NULL, [PWD] [varbinary](100) NULL, [rowguid] [uniqueidentifier] NULL, PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
This syntax is invalid for several reasons. The NOT FOR REPLICATION
clause on the IDENTITY column isn't supported. Nor are the two ON PRIMARY
clauses, the ALLOW_ROW_LOCKS
clause, and the ALLOW_PAGE_LOCKS
clause. However, the following syntax is valid:
CREATE TABLE [dbo].[Users]( [ID] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](50) NULL, [NTUserName] [nvarchar](128) NULL, [Domain] [nvarchar](50) NOT NULL, [Intro] [nvarchar](100) NULL, [Title] [nvarchar](50) NOT NULL, [State] [nvarchar](10) NOT NULL, [Country] [nvarchar](100) NULL,
[PWD] [varbinary](100) NULL, [rowguid] [uniqueidentifier] NULL, PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF))
For detailed information about exactly what is supported and what isn't, visit http://msdn.microsoft.com/en-us/library/ee336267.aspx
.
The list of unsupported T-SQL statements is long, but that isn't as negative a thing as it may appear. In most cases, unsupported statements are operating-system or hardware related, and they don't apply in the SQL Azure environment.
Because there are so many unsupported statements, this appendix doesn't list them all. You can find a complete list at http://msdn.microsoft.com/en-us/library/ee336253.aspx
. Table B-3 provides a shorter list, highlighting some unsupported statements that you should particularly be aware of.
Table B.3. Unsupported T-SQL Statements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
|
|
If you've been following SQL Azure since its initial release to the public, you realize that Microsoft has come a long way in supporting much of the functionality and many of the data types found in your local, on-premises instance of SQL Server. Table B-4 lists those data types currently supported in SQL Azure as of Service Update 4.
Table B.4. SQL Azure Supported Data Types
Numerics |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
Date and time |
|
| |
| |
| |
| |
| |
Character strings |
|
| |
| |
Unicode character strings |
|
| |
| |
Binary strings |
|
| |
| |
Spatial |
|
| |
Other |
|
| |
| |
| |
| |
|
For a complete list of supported methods for the geography, geometry, hierarchyid
, and xml
data types, go to http://msdn.microsoft.com/en-us/library/ee336233.aspx
.