I'm executing these from microsoft sql server 2016 but I received an error message. Please help me with this.

LeaIlagan 21 Reputation points
2021-02-09T06:16:24.297+00:00

CREATE TABLE SensorData
{
SensorDataId int identity(1,1) primary key not null,
TemperatureData Decimal(18,6),
HumidityData Decimal(18,6),
pHLevelData Decimal(18,6),
NitrateData Decimal (18,6),
LogDateTime datetime DEFAULT GETDATE()
}

This is the message I receive.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '{'.

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,666 questions
0 comments No comments
{count} votes

Accepted answer
  1. EchoLiu-MSFT 14,591 Reputation points
    2021-02-09T06:26:49.26+00:00

    Hi @LeaIlagan ,

    Welcome to the Microsoft TSQL Q&A Forum!

    When creating a table, the standard syntax of tsql is to use (), not {},please refer to:

    CREATE TABLE SensorData  
    (  
    SensorDataId int identity(1,1) primary key not null,  
    TemperatureData Decimal(18,6),  
    HumidityData Decimal(18,6),  
    pHLevelData Decimal(18,6),  
    NitrateData Decimal (18,6),  
    LogDateTime datetime DEFAULT GETDATE()  
    )  
    

    If you have any question, please feel free to let me know.
    If the response is helpful, please click "Accept Answer" and upvote it.

    Regards
    Echo


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Tom Cooper 8,471 Reputation points
    2021-02-09T06:34:37.517+00:00

    You used braces { } instead of parenthesis ( ). So you want

    CREATE TABLE SensorData
    (
    SensorDataId int identity(1,1) primary key not null,
    TemperatureData Decimal(18,6),
    HumidityData Decimal(18,6),
    pHLevelData Decimal(18,6),
    NitrateData Decimal (18,6),
    LogDateTime datetime DEFAULT GETDATE()
    )
    

    Tom


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.