Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 table definition with SQL help

Author  Topic 

hybridoutlaw
Starting Member

12 Posts

Posted - 2010-07-19 : 14:14:30
I have created the below database and forgot to add the ssn field to my table. After adding the ssn field, I receive the following error: Msg 213, Level 16, State 1, Line 68
Column name or number of supplied values does not match table definition.

Why is it not taking the ssn values after I added the ssn field? Any help is greatly appreciated.


USE KUDLER
CREATE TABLE JOB_TITLE
(
eeo_1_classification VARCHAR (20) NOT NULL,
job_title_id VARCHAR (5) PRIMARY KEY,
job_title VARCHAR (50) NOT NULL,
j_description VARCHAR (100) NOT NULL,
exempt VARCHAR (4) NOT NULL
)

CREATE TABLE employee
(
id_num INT IDENTITY (1, 1) PRIMARY KEY,
last_name VARCHAR (15) NOT NULL,
first_name VARCHAR(15) NOT NULL,
address VARCHAR (50) NOT NULL,
city VARCHAR (20) NOT NULL,
state VARCHAR (2) NOT NULL,
telephone_area_code INT NOT NULL,
telephone_number VARCHAR (10) NOT NULL,
eeo_1_classification VARCHAR (20) NOT NULL,
hire_date DATETIME NOT NULL,
salary DECIMAL (10,2),
gender CHAR(1) NOT NULL,
date_of_birth VARCHAR (100) NOT NULL,
ssn VARCHAR (10) NOT NULL,
job_title_id VARCHAR (5)
CONSTRAINT FK_Employee_Job_title
FOREIGN KEY REFERENCES Job_title (Job_title_id)
)

INSERT INTO JOB_TITLE VALUES
('Office Clerical', '071',
'Accounting Clerk',
'Maintains and computes all records',
'No');

INSERT INTO JOB_TITLE VALUES
('Officials Managers', '062',
'Asst Manager',
'Supervises and coordinates workers',
'Yes');

INSERT INTO JOB_TITLE VALUES
('Sales Worker', '053',
'Bagger',
'Places customer items in bags',
'No');

INSERT INTO JOB_TITLE VALUES
('Sales Workers', '084', 'Cashier', 'itemize and total customer’s purchases', 'No');

INSERT INTO JOB_TITLE VALUES
('Technician','095','Computer Support Specialist', 'Updates software maintain hardware provides training technical assistance', 'Yes');

INSERT INTO JOB_TITLE VALUES
('Officials Managers', '016','Director of Finance Accounting', 'plans and directs the finance and accounting activities','Yes');

INSERT INTO JOB_TITLE VALUES
('Craft Workers', '027', 'Retail Asst. Bakery & Pastry','monitors workers','No');

INSERT INTO JOB_TITLE VALUES
('Operatives', '038', 'Retail Asst. Butchers and Seafood Specialist', 'monitors workers', 'No');

INSERT INTO JOB_TITLE VALUES
('Stocker', '049', 'Office clerical','Stores, prices and restocks merchandise displays in store', 'No');

INSERT INTO EMPLOYEE VALUES
('Edelman','Glenn','175 Bishops Lane','La_Jolla','CA','619','555-0199','123456789',
'07-OCT-2003',21500.75,'M','01-JAN-1946','084');

INSERT INTO Employee VALUES
(
'Edelman','Glenn','175 Bishops Lane','La_Jolla','CA','619','555-0199','123456789',
'07-OCT-2003',21500.75,'M','01-JAN-1946','084');

INSERT INTO Employee VALUES
(
'McMullen','Eric','763 Church St','Lemon Grove','CA','619','555-0135','234567890',
'1-NOV-2002',13500.00,'M','03-FEB-2010','084');

INSERT INTO Employee VALUES
('Slentz','Raj','123 Torrey Dr.','North Clairmont','CA','619','555-0123','157863498',
'1-JUN-2000',48000.00,'M','25-MAR-2010','016');

INSERT INTO Employee VALUES
('Broun','Erin','2045 Parkway Apt.2B','Encinitas','CA','760','555-0100','654983473',
'12-MAR-2003',10530.00,'F','19-APR-2010','053');

INSERT INTO Employee VALUES
('Carpenter','Donald','927 Second ST.', 'Encinitas','CA','619','555-0154','468656425',
'1-NOV-2003', 15000.00,'M','05-MAY-1992','071');

INSERT INTO Employee VALUES
('Esquivez','David','10983 N. Coast Hwy Apt 902','Encinitas','CA','760','555-0108','560348976',
'25-JUL-2003',18500.00,'M','12-JUN-1985','038');

INSERT INTO Employee VALUES
('Sharp','Nancy','10793 Monteciono Rd','Ramona','CA','858','555-0135','556332157',
'12-JUL-2003',21000.00,'F','29-JULY-1986','053');

Select * from employee
Select * from job_title

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-19 : 14:29:10
Have a look at your insert statements on table Employee.
The values are not fitting to the columns.
Better do this:
insert into employees(col1name1, colname2, ...)
values ('value_for_col1', value_for_col2', ...)


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

hybridoutlaw
Starting Member

12 Posts

Posted - 2010-07-19 : 14:37:30
Thanks for your reply. I just tried that and I'm still getting the same error. It's as if I'm missing something in the insert statement. I can't figure it out... would you mind helping me out on this?
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-07-19 : 14:43:33
try matching your tabler def to the insert statement. As Webfred suggested your columns do not match up:
INSERT INTO Employee VALUES
(
'McMullen',
'Eric',
'763 Church St',
'Lemon Grove',
'CA',
'619',
'555-0135',
'234567890',
'1-NOV-2002',
13500.00,
'M',
'03-FEB-2010', --DOB
'084') -- SSN or Job Title? One is missing..
Go to Top of Page

hybridoutlaw
Starting Member

12 Posts

Posted - 2010-07-19 : 15:02:22
That was my mistake. Thank you so much for helping me out. A second set of eyes always works great. Much appreciated!
Go to Top of Page
   

- Advertisement -