I had this strange problem when adding a column to an existing table.
The existing table looks like this:
CREATE TABLE [BinaryAssets].[BinaryAssets]( [BinaryAssetId] [int] IDENTITY(1,1) NOT NULL, [BinaryAssetStructureId] [int] NOT NULL, [Name] [nvarchar](max) NOT NULL, [Created_By] [int] NOT NULL, [Created_On] [bigint] NOT NULL, [Modified_By] [int] NOT NULL, [Modified_On] [bigint] NOT NULL, [Active] [bit] NOT NULL, CONSTRAINT [PK_BinaryAsset] PRIMARY KEY NONCLUSTERED ( [BinaryAssetId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
Now the sql I'm trying to execute looks like this:
ALTER TABLE BinaryAssets.BinaryAssets ADD [Version] INT NOT NULL CONSTRAINT DF_BinaryAssets_Version DEFAULT 1 ALTER TABLE BinaryAssets.BinaryAssets DROP CONSTRAINT DF_BinaryAssets_Version
When I try to execute, I get sqlexception (see Title).
Now, I donβt think my table exceeds 8060, so the problem is here. The strange thing is that when I change, for example, the name from nvarchar (max) to nvarchar (100), then execute my new sql, and then change back 100 to MAX, it works ... the logic seems far here.
Can someone tell me what I'm doing wrong here?