Query is as follows:
create TABLE tbl_temp (
[ref] numeric(18),
[item_code] varchar(50),
[item_desc] nvarchar(150),
[Qty] smallint) PRIMARY KEY (ref, item_code))
Returning error:
Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'PRIMARY'.
Try this way:
create TABLE tbl_temp
(
[ ref] numeric(18),
[item_code] varchar(50),
[item_desc] nvarchar(150),
[Qty] smallint,
PRIMARY KEY (ref, item_code)
)
But better way to do that is to use constraint
as below:
create TABLE tbl_temp
(
[ ref] numeric(18),
[item_code] varchar(50),
[item_desc] nvarchar(150),
[Qty] smallint,
CONSTRAINT pk_tbl_temp PRIMARY KEY (ref, item_code)
)
or
create TABLE tbl_temp
(
[ ref] numeric(18),
[item_code] varchar(50),
[item_desc] nvarchar(150),
[Qty] smallint
)
ALTER TABLE tbl_temp
ADD CONSTRAINT pk_tbl_temp PRIMARY KEY (ref, item_code)
Is better way because you set a friendly name for your PK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With