How to create SQL Server tables with 5 columns:
1 IdP column name. 2,3,4,5 column name: a / b / c / d
Features:
1 column (int) is to have 450 rows, with IdP numbered from 1 to 450.
The 2nd column (time) is to have a default value of 08:00:00
3rd column (int) default = 1
4th column (int) default = 0
5 column (int) default = NULL
I have
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Table]( [IdP] [int] NULL, [a] [time](0) DEFAULT 08:00:00, [b] [int] DEFAULT 1, [c] [int] DEFAULT 0, [d] [nvarchar](5) NULL ) ON [PRIMARY] GO
Error:
Incorrect syntax near object “:”.
Advertisement
Answer
Check with supplying time value as shown below. Here is the time (Transact-SQL) reference in SQL Server.
[a] [time](0) DEFAULT '08:00:00'
Time and date values are supplied in the single quote. Also table name should be different not the reserved keyword and it is just a suggestion.
Here is the Demo Link.