Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expecting ID Error - SQL Server

Tags:

sql-server

I have a problem when i create a table in SQL Server

once i chose DOUBLE as the data type, the error jumped on my face !!!

THIS is the following code :

CREATE TABLE BATCH 
( Product_Name  VARCHAR(200) NOT NULL, 
  Product_Brand VARCHAR(100) NOT NULL, 
  CONSTRAINT Price_FK FOREIGN KEY (Product_Name,Product_Brand)REFERENCES Product   (Product_Name,Product_Brand),
  BATCH_Date AS GETDATE(),
  BATCH_OriginalPrice DOUBLE NOT NULL DEFAULT 0,
  BATCH_TAX DOUBLE NOT NULL DEFAULT 0,
  BATCH_ProductCost DOUBLE NOT NULL DEFAULT 0 ,
) 

The error is like this after each double Incorrect syntax near the keyword 'NOT'

and when i pass the mouse over it, it says " Incorrect syntax near 'NOT'. Expecting ID "

Can someone tell me what's the problem !!!

like image 362
Wassan Avatar asked Dec 06 '22 06:12

Wassan


1 Answers

double isn't a data type in SQL, you'll have to use float or real.

With your example you could use money as well.

related: What represents a double in sql server?

like image 192
hkf Avatar answered Dec 29 '22 00:12

hkf