Share via

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 '{'.

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

0 comments No comments

Answer accepted by question author

EchoLiu-MSFT 14,626 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.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Tom Cooper 8,501 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

    Was this answer helpful?


Your answer

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