I'm new at programming with Microsoft SQL and am trying to design a table that supports storing data over time that can eventually be used to plot a graph. I found an article (https://www.simple-talk.com/sql/database-administration/database-design-a-point-in-time-architecture/) that seems to point towards a design that could support something like that. However, the test code on it for CREATE TABLE doesn't seem to work when I try it.
CREATE TABLE [dbo].[Test_PTA_Table](
[TestTablePK] [int] IDENTITY(1,1) NOT NULL,
[TestTableText] [varchar](50)
COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DateCreated] [datetime]
NOT NULL CONSTRAINT [DF_Test_PTA_Table_DateCreated]
DEFAULT (getdate()),
[DateEffective] [datetime] NOT NULL,
[DateEnd] [datetime] NULL,
[OperatorCode] [varchar](50)
COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DateReplaced] [datetime] NULL
CONSTRAINT [DF_Test_PTA_Table_DateReplaced]
DEFAULT (getdate()),
CONSTRAINT [PK_Test_PTA_Table] PRIMARY KEY CLUSTERED
(
[TestTablePK] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
This throws an error on my machine, saying:
Msg 170, Level 15, State 1, Line 22
Line 22: Incorrect syntax near '('.
Curiously enough, it works as soon as I remove the offending line of code WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) so I'm not sure what is going on here. Why is that line of code causing problems when the documentation for the Create Table syntax supports it in their help file? Knowing me the issue is probably a missing silly comma or something, but any help would be greatly appreciated. Thanks!