When I try
Solution 1 I get
Quote:
Msg 102, Level 15, State 1, Line 29
Incorrect syntax near 'nip'.
In the line indicated. Why? Adding that comma is incorrect and there is a missing closing bracket at the end of the query
CREATE TABLE [presence](
[id_presence] [int] IDENTITY (1, 1) NOT NULL ,
[tgl] [datetime] NULL ,
[nip] [char] (2),
CONSTRAINT [fk_nips] FOREIGN KEY [nip]
REFERENCES [school] ([NIP] )
When I try
Solution 2 I also get an error
Quote:
Msg 102, Level 15, State 1, Line 17
Incorrect syntax near ')'.
Why. Still missing the closing bracket
CREATE TABLE [presence](
[id_presence] [int] IDENTITY (1, 1) NOT NULL,
[tgl] [datetime] NULL,
[nip] [char] (2) CONSTRAINT [fk_nips] FOREIGN KEY ([nip])
REFERENCES [school] ([NIP])
Here is the
correct solution. Why? Only difference between the original version and the working version is that closing bracket. Judicious use of whitespace can help spot things like this.
CREATE TABLE [presence]
(
[id_presence] [int] IDENTITY (1, 1) NOT NULL ,
[tgl] [datetime] NULL ,
[nip] [char] (2) CONSTRAINT [fk_nips]
FOREIGN KEY ([nip]) REFERENCES [school] ([NIP])
);
I did actually test my version, which clearly the previous two posters did not.