Windows Azure SQL Server T-SQL issues

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

When you move one database form SQL Server to Windows Azure SQL Server by using of SQL scripts you will run into several issues which are not that obvious.
SQL Server in Windows Azure platform does not support full T-SQL. Here are few examples:

This is the simple table which I want to move to Windows Azure SQL Server:

USE AzureDb

CREATE TABLE [calc].[TClient](
    [ID] [bigint] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](50) NOT NULL,
    [ChangedBy] [nvarchar](50) NULL,
    [ChangedAt] [datetime] NULL,
    [CreatedBy] [nvarchar](50) NULL,
    [CreatedAt] [datetime] NULL,
    [ExternalId] [nvarchar](256) NULL,
    [ExternalSystemId] [nvarchar](20) NULL,
CONSTRAINT [PK_TMandate] 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]

After you start this script following error appears:

Msg 40508, Level 16, State 1, Line 1
USE statement is not supported to switch between databases. Use a new connection to connect to a different Database
.

No problem. Just remove statement USE AzureDb.

Now execute script again and uupss:


Msg 40517, Level 16, State 1, Line 14
Keyword or statement option 'pad_index' is not supported in this version of SQL Server.

To work around this issue remove following part of script:

WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

 

At the end you script should look like:

CREATE TABLE [tracking].[TClient](
    [ID] [bigint] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](50) NOT NULL,
    [ChangedBy] [nvarchar](50) NULL,
    [ChangedAt] [datetime] NULL,
    [CreatedBy] [nvarchar](50) NULL,
    [CreatedAt] [datetime] NULL,
    [ExternalId] [nvarchar](256) NULL,
    [ExternalSystemId] [nvarchar](20) NULL,
CONSTRAINT [PK_TMandate] PRIMARY KEY CLUSTERED
(
    [ID] ASC
))

 

This will work fine. This post might help you to solve your problem. Unfortinatelly my problem is that my script has contained 100+ tables Sad smile


Posted Dec 12 2010, 12:20 AM by Damir Dobric
Filed under: ,

Comments

Windows Azure SQL Server T-SQL issues – Damir Dobric Posts … - sql wrote Windows Azure SQL Server T-SQL issues – Damir Dobric Posts … - sql
on 12-12-2010 5:32

Pingback from  Windows Azure SQL Server T-SQL issues – Damir Dobric Posts … - sql

developers.de is a .Net Community Blog powered by daenet GmbH.