SQL Azure Management Portal returns error as An exception occurred while executing the Transact-SQL statement
While creating a new Table in SQL Azure using SQL Azure Management Portal, you might see the following error:
While collecting this error details you will see the following crucial information:
An error was encountered while applying the changes. An exception occurred while executing the Transact-SQL statement:
DECLARE @PageSize float
SET @PageSize= 8.0;
use [master]
SELECT
CAST(OBJECTPROPERTY(tbl.object_id, N'IsIndexable') AS bit) AS [Table_IsIndexable],
tbl.uses_ansi_nulls AS [Table_IsAnsiNullsOn],
CAST(OBJECTPROPERTY(tbl.object_id,N'IsQuotedIdentOn') AS bit) AS [Table_IsQuotedIdentifierOn],
CAST(tbl.is_tracked_by_cdc AS bit) AS [Table_IsChangeDataCaptureOn],
ISNULL( (select sum (spart.row_count) from sys.dm_db_partition_stats AS spart where spart.object_id = tbl.object_id and spart.index_id = 1), 0) AS [Table_RowCount],
ISNULL((SELECT @PageSize * SUM(p.in_row_data_page_count + p.lob_used_page_count + p.row_overflow_used_page_count)
FROM sys.dm_db_partition_stats AS p
WHERE p.object_id = tbl.object_id),0.0)
AS [Table_DataSpaceUsed],
ISNULL((SELECT @PageSize * SUM(p.used_page_count - CASE WHEN p.in_row_data_page_count
> 0 THEN p.in_row_data_page_count ELSE p.used_page_count END)
FROM sys.dm_db_partition_stats AS p
WHERE p.object_id = tbl.object_id),0.0)
AS [Table_IndexSpaceUsed],
tbl.name AS [Table_Name],
tbl.object_id AS [Table_ID],
CAST(tbl.is_ms_shipped AS bit) AS [Table_IsSystemObject],
tbl.object_id AS [Table_$Identity],
CAST(1 AS smallint) AS [Table_$DbId],
tbl.create_date AS [Table_CreateDate]
FROM
sys.schemas AS s
JOIN sys.tables AS tbl ON (1=1)
WHERE
((CAST(1 AS smallint)=<msparam>1</msparam> AND s.name=<msparam>dbo</msparam>)) AND
(s.schema_id=tbl.schema_id)
.The user does not have permission to perform this action.
Reason:
This will happen when you have used Master database in management portal as you are not allow to create a new table against the Master DB.
Solution:
When you open another database from your SQL Azure service and try creating a table in database, there should not be any problem.