Appendix B. SQL Azure Quick Reference

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.

Note

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.

Supported T-SQL

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

ALTER ROLE

DECLARE CURSOR

OPEN

ALTER SCHEMA

DELETE

OPTION Clause

ALTER VIEW

DENY Object Permissions

ORDER BY Clause

APPLOCK_MODE

DENY Schema Permissions

OUTPUT Clause

APPLOCK_TEST

DROP LOGIN

OVER Clause

BEGIN_TRANSACTION

DROP PROCEDURE

PRINT

BEGIN...END

DROP ROLE`

RAISERROR

BINARY_CHECKSUM

DROP SCHEMA

RETURN

BREAK

DROP STATISTICS

REVERT

CAST and CONVERT

DROP SYNONYM

REVOKE Object Permissions

CATCH (TRY...CATCH)

DROP TYPE

REVOKE Schema Permissions

CEILING

DROP USER

ROLLBACK TRANSACTION

CHECKSUM

DROP VIEW

ROLLBACK WORK

CLOSE

END (BEGIN...END)

SAVE TRANSACTION

COALESCE

EXCEPT and INTERSECT

SELECT @local_variable

COLLATE

FETCH

SELECT Clause

COLUMNPROPERTY

FOR Clause (XML and BROWSE)

SET @local_variable

COMMIT TRANSACTION

FROM

SWITCHOFFSET

COMMIT WORK

GO

TERTIARY_WEIGHTS

COMPUTE

GOTO

TODATETIMEOFFSET

CONTEXT_INFO

GRANT Object Permissions

TOP

CONTINUE

GRANT Schema Permissions

TRIGGER_NESTLEVEL

CONVERT

GROUP BY

TRUNCATE TABLE

CREATE ROLE

GROUPING_ID

TRY...CATCH

CREATE SCHEMA

HashBytes

UNION

CREATE STATISTICS

HAVING

UPDATE

CREATE VIEW

Hints (Query, Table, Join, etc)

UPDATE STATISTICS

CRYPT_GEN_RANDOM

IDENTITY (Property)

USER

CURRENT_REQUEST_ID

IF...ELSE

SWITCHOFFSET

CURSOR_STATUS

INSERT BULK

WAITFOR

DBCC SHOW_STATISTICS

IS [NOT] NULL

WHERE

DEALLOCATE

MERGE

WHILE

DECLARE @local_variable

MIN_ACTIVE_ROWVERSION

WITH (Common Table Exp.)

Partially Supported T-SQL

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

ALTER AUTHORIZATION

CREATE PROCEDURE

DROP TRIGGER

ALTER DATABASE

CREATE SPATIAL INDEX

DISABLE TRIGGER

ALTER FUNCTION

CREATE SYNONYM

ENABLE TRIGGER

ALTER INDEX

CREATE TABLE

EXECUTE

ALTER LOGIN

CREATE TRIGGER

EXECUTE AS

ALTER PROCEDURE

CREATE TYPE

EXECUTE AS Clause

ALTER TABLE

CREATE USER

GRANT Database Permissions

ALTER TRIGGER

CREATE VIEW

GRANT Database Principle Perm.

ALTER USER

DENY Database Permissions

GRANT Type Permissions

ALTER VIEW

DENY Database Principle Perm.

INSERT

CREATE DATABASE

DENY Type Permissions

REVOKE Database Permissions

CREATE FUNCTION

DROP DATABASE

REVOKE Database Principle Perm.

CREATE INDEX

DROP INDEX

REVOKE Type Permissions

CREATE LOGIN

DROP TABLE

USE

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>

    • FILLFACTOR

    • ON

    • NOT FOR REPLICATION

  • <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.

Unsupported T-SQL

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

BACKUP CERTIFICATE

DBCC CHECKTABLE

BACKUP MASTER KEY

DBCC DBREINDEX

BACKUP SERVICE MASTER KEY

DBCC DROPCLEANBUFFERS

CHECKPOINT

DBCC FREEPROCCACHE

CONTAINS

DBCC HELP

CREATE/DROP AGGREGATE

DBCC PROCCACHE

CREATE/DROP RULE

DBCC SHOWCONTIG

CREATE/DROP XML INDEX

DBCC SQLPERF

CREATE/DROP/ALTER APPLICATION ROLE

DBCC USEROPTIONS

CREATE/DROP/ALTER ASSEMBLY

KILL

CREATE/DROP/ALTER CERTIFICATE

NEWSEQUENTIALID

CREATE/DROP/ALTER DEFAULT

OPENQUERY

CREATE/DROP/ALTER FULLTEXT (CATALOG, INDEX, STOPLIST)

OPENXML

CREATE/DROP/ALTER PARTITION FUNCTION

RECONFIGURE

CREATE/DROP/ALTER QUEUE

RESTORE

CREATE/DROP/ALTER RESOURCE POOL

SELECT INTO Clause

CREATE/DROP/ALTER SERVICE

SET ANSI_DEFAULTS

CREATE/DROP/ALTER XML SCHEMA COLLECTION

SET ANSI_NULLS

DBCC CHECKALLOC

SET ANSI PADDING_OFF

DBCC CHECKDB

SET OFFSETS

DBCC CHECKIDENT

WITH XML NAMESPACES

Supported Data Types

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

bigint

 

bit

 

decimal

 

int

 

money

 

numeric

 

smallint

 

smallmoney

 

tinyint

 

float

 

real

Date and time

date

 

datetime2

 

datetime

 

datetimeoffset

 

smalldatetime

 

time

Character strings

char

 

varchar

 

text

Unicode character strings

nchar

 

nvarchar

 

ntext

Binary strings

binary

 

varbinary

 

image

Spatial

geography

 

geometry

Other

cursor

 

hierarchyid

 

sql_variant

 

table

 

timestamp

 

uniqueidentifier

 

xml

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset