On SQL server 2005, I have a table defined as follow:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DebugTrace](
[Timestamp] [datetime] NOT NULL CONSTRAINT [DF_DebugTrace_Timestamp] DEFAULT (getdate()),
[Log] [nvarchar](max) NOT NULL,
[id] [int] IDENTITY(1,1) NOT NULL,
CONSTRAINT [PK_DebugTrace] 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]
As you can see, the Timestamp column has a default value set to GetDate().
From the SQL Server Management Studio (running locally on the SQL server), the below code runs fine:
insert into DebugTrace ([Log])
values ('test')
The "same" code ran my workstation fails:
DebugTrace trace = new DebugTrace();
trace.Log = "test from code";
DebugTraces.InsertOnSubmit(trace);
SubmitChanges();
The exception thrown is:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Both requests do not set the Timestamp and rely on the default value to set the column value. Therefore how can the GetDate() function trigger such an exception?
P.S. to request is run from different machines but with the same Windows account