Monday, 12 August 2013

The identity column must be of data type int, bigint, smallint, tinyint, decimal, or numeric

The identity column must be of data type int, bigint, smallint, tinyint,
decimal, or numeric

I have created a database project in Visual Studio 2012, with target
platform set to 'Windows Azure SQL Database'. I added a table like:
CREATE TABLE [dbo].[Organization]
(
[Id] UNIQUEIDENTIFIER NOT NULL PRIMARY KEY NONCLUSTERED IDENTITY,
[Name] NVARCHAR(100) NOT NULL,
[CreationDate] DATETIME NOT NULL DEFAULT GetDate()
)
GO
CREATE CLUSTERED INDEX [IX_Organization_CreationDate] ON
[dbo].[Organization] ([CreationDate])
But it keeps complaining about:
Error 1 SQL71518: The identity column '[dbo].[Organization].[Id]' must
be of data type int, bigint, smallint, tinyint, decimal, or numeric with a
scale of 0, and the column must not be nullable.
C:\Projects\Gastrology\MGP\trunk\Sources\Cfg.Mgp.Infrastructure.Database\Organization.sql
3 2 Cfg.Mgp.Infrastructure.Database
Anyone knows why I can't create a primary key of type guid? What Am I
doing wrong?
Thanks!

No comments:

Post a Comment