we are currently looking at setting our string columns to nvarchar(max)
rather than specifying a specific length to prevent any problems where there could be not enough room in the database to store the string . Im just wondering if this is a good thing or could it cause any problems since it was ok to do then why specify a length like nvarchar(10)
rather than nvarchar(max)
. We also use varbinary(max)
a lot since we dont know how much binary data we will need so Im not sure how much this is an effect either give that our inserts are not as fast as I think they should be . This is an example table:
CREATE TABLE [dbo].[SAMPLETABLE] (
[ID] [uniqueidentifier] NOT NULL,
[FIELD1] [int] NOT NULL,
[FIELD2] [nvarchar] (2000) NULL,
[FIELD3] [nvarchar] (max) NULL,
[FIELD4] [uniqueidentifier] NULL,
[FIELD5] [int] NULL,
[FIELD6] [nvarchar] (2000) NULL,
[FIELD7] [varbinary] (max) NULL,
[FIELD8] [varbinary] (max) NULL,
[FIELD9] [varbinary] (max) NULL,
[FIELD10] [uniqueidentifier] NULL,
[FIELD11] [nvarchar] (2000) NULL,
[FIELD12] [varbinary] (max) NULL,
[FIELD13] [varbinary] (max) NULL,
[FIELD14] [bit] NULL,
[FIELD15] [uniqueidentifier] NULL,
[FIELD16] [varbinary] (max) NULL,
[FIELD17] [bit] NULL,
[FIELD18] [tinyint] NULL,
[FIELD19] [datetime] NULL,
[FIELD20] [nvarchar] (2000) NULL,
PRIMARY KEY CLUSTERED
(
[ID] ASC
)
) ON [PRIMARY]
GO
Given a table design like that and changing the nvarchar(2000)
to nvarchar(max)
would that make things any worse(or better)? Does sqlserver frown upon designs like this?