question

vio avatar image
vio asked

sql code that give this error

CREATE TABLE  Payroll(                    
    Emp_NINO    VARCHAR (13) NOT NULL,                    
    Mth_Shifts  NUMERIC (2) NOT NULL,                    
    Pay_Rate        NUMERIC (2) NOT NULL,                    
             Emp_Mth_Salary NUMERIC (5) NOT NULL,                     
-- This indicates which attribute(s) uniquely identify each row of data.                    
CONSTRAINT  pk_ Payroll  PRIMARY KEY (Mth_Shifts, Pay_Rate));                    

i wrote the code and the error that appears on my screen is "missing right paranthesis".i'm trying to understand where is the error!!!!!!Thx a lot!

sql-server-2008create
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

is this SQL Server or Oracle?
0 Likes 0 ·
Piotr Rodak avatar image
Piotr Rodak answered

Try to format the code properly, oppening and closing brackets of CREATE TABLE in separate lines. It will be easier for you to find the problem. I see there is a space in the name of the constraint, and if the command is not formatted correctly, inline comment may affect the syntax. I find this much cleaner:

CREATE TABLE Payroll            
(             
Emp_NINO VARCHAR (13) NOT NULL,             
Mth_Shifts NUMERIC (2) NOT NULL,             
Pay_Rate NUMERIC (2) NOT NULL,             
Emp_Mth_Salary NUMERIC (5) NOT NULL,             
-- This indicates which attribute(s) uniquely identify each row of data.             
CONSTRAINT pk_Payroll PRIMARY KEY (Mth_Shifts, Pay_Rate)            
);            

You should use this '101010' icon to indicate that part of your post is code actually, then the formatting will be easier. I found that line breaks do not work very well in this editor.

The above command works on my machine.

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

user-1130 (google) 1 avatar image
user-1130 (google) 1 answered

plz format u r code properly if not necessaary romeve the comment line

CREATE TABLE Payroll ( Emp_NINO VARCHAR (13) NOT NULL, Mth_Shifts NUMERIC (2) NOT NULL, Pay_Rate NUMERIC (2) NOT NULL, Emp_Mth_Salary NUMERIC (5) NOT NULL, -- This indicates which attribute(s) uniquely identify each row of data. CONSTRAINT pk_Payroll PRIMARY KEY (Mth_Shifts, Pay_Rate) );

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.