Problem when executing SQL Server statement

0

I have a problem executing a statement in SQL Server

CREATE TABLE venta (
    idVenta INTEGER PRIMARY KEY, 
    Fecha DATE NOT NULL, 
    Cliente_Cedula INTEGER NOT NULL,
    producto_idProducto INTEGER NOT NULL,
    empleado_Cedula INTEGER NOT NULL,
    cantidad INTEGER NOT NULL,
    FOREIGN KEY ('Cliente_Cedula')
    REFERENCES cliente ('Cedula')
    FOREIGN KEY ('empleado_Cedula')
    REFERENCES empleado ('Cedula')
    FOREIGN KEY ('producto_idProducto')
    REFERENCES producto ('idProducto')
    );

Error:

Incorrect syntax near 'Client_Cell'

    
asked by Sebastian Salazar 28.02.2018 в 02:05
source

1 answer

0

After constraint you have to put the name of the constraint, before telling it what type it is. For the index more of the same. Corrected would look like this:

CREATE TABLE venta (
idVenta INTEGER PRIMARY KEY, 
Fecha DATE NOT NULL, 
Cliente_Cedula INTEGER NOT NULL,
producto_idProducto INTEGER NOT NULL,
empleado_Cedula INTEGER NOT NULL,
cantidad INTEGER NOT NULL,
INDEX fk_venta_cliente NONCLUSTERED (Cliente_cedula),
constraint fk_venta_empleado FOREIGN KEY  (empleado_Cedula) REFERENCES empleado (Cedula),
constraint fk_venta_producto FOREIGN KEY  (producto_idProducto) REFERENCES producto (idProducto)
);
    
answered by 28.02.2018 в 17:35