2010-07-07 6 views
-1

가능한 중복 : 나는 테이블이 채워 수없는 이유
Incorrect syntax near insert의 구문이 잘못

. 전에는 효과가 있었지만 지금은 왜 돌아 가지 않을지 모르겠습니다.

CREATE DATABASE Mort; 
Go 


USE Mort; 
----------------------------------- 
/* 
**This script creates the 
** Employee table with the foreign key 
*/ 
----------------------------------- 

---------------------------------------------------- 
/* I chose Job_title as the PRIMARY KEY. 
**All rows must be unique. There is a Job_title 
**column in the Employee table that can be used as a 
**foreign key. 
*/ 
/* 
**This script creates the 
** Job title table 
*/ 
---------------------------------------------------- 
CREATE TABLE 
Job_title 
(Job_title varchar (50) PRIMARY KEY, 
EEO_1_Classification varchar(200), 
Job_description varchar(250), 
Exempt_Non_Exempt_Status bit); 
Go 

CREATE TABLE 
Employee 
(Emp_id int NOT NULL IDENTITY(1,1)PRIMARY KEY, 
Last_name varchar(25),  
First_name varchar(25), 
Address varchar(40),   
City varchar (15), 
State char(2), 
Telephone_area_code varchar(3),  
Telephone_number varchar(8),   
Job_title varchar(50) foreign key references job_title(job_title), 
Hire_date smalldatetime,  
Wage money, 
Gender char(1), 
Race varchar(25), 
Age int); 
----------------------------------------------------------------------------------------------------- 
/* (3.1) This script inserts employee records 
** for both the administrative offices 
** and the Del Mar location 
*/ 
------------------------------------------------------------------------------------------------- 

USE Mort; 
Go 


INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('McNamara', 
'Juanita', 
'923 Parkway', 
'La Jolla', 
'CA', 
'619', 
'555-0208', 
'Accounting Clerk', 
'10/07/2003', 
'$12.75', 
'F', 
'Hispanic', 
32); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('Stephens', 
'Harvey', 
'7863 High Bluff Drive', 
'La Jolla', 
'CA', 
'619', 
'555-0123', 
'Dir. of Fin. 
& Acct.', 
'3/1/1998', 
'$75,000.00', 
'M', 
'Caucasian', 
51); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage,  
Gender,  
Race,   
Age) 

VALUES 
('Vu', 
'Matthew', 
'981 Torrey Pines Road', 
'La Jolla', 
'CA', 
'619', 
'555-0138', 
'Computer Support Specialist', 
'8/16/2000', 
'$18.50', 
'M', 
'Asian', 
26); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('Nguyen', 
'Meredith', 
'10583 Arenas ST. ', 
'La Jolla ', 
'CA', 
'619', 
'555-0102', 
'Computer Support Specialist ', 
'9/27/1998 ', 
'$21.50 ', 
'M', 
'Caucasian', 
25); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('Avery', 
'Ledonna', 
'198 Governor Dr.', 
'Del Mar', 
'CA', 
'619', 
'555-0135', 
'Asst. - Bakery & Pastry', 
'3/28/2003', 
'$10.50', 
'F', 
'African American', 
23); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('Drohos', 
'Craig', 
' ', 
'Selano Beach', 
'CA', 
'619', 
'555-0202', 
'Assistant Manager', 
'6/15/2000', 
'$51,000.00 ', 
'M', 
'Caucasian', 
32); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('Meier', 
'Elaine', 
'9703 Orchid Lane', 
'Del Mar', 
'CA', 
'858', 
'555-0112', 
'Cashier', 
'9/10/2000', 
'$10.25', 
'F', 
'Asian', 
51); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('Quillian', 
'Stanley', 
'98542 Wandering Road Apt 2-B', 
'Del Mar', 
'CA', 
'760', 
'555-0198', 
'Asst. - Butchers & Seafood Specialists', 
'12/16/1999', 
'$11.50 ', 
'M', 
'American Indian', 
29); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('Tyink', 
'Thomas', 
'87592 Pacific Heights Blvd.', 
'Del Mar', 
'CA', 
'858', 
'555-0159', 
'Asst. - Bakery & Pastry', 
'5/1/2001', 
'$9.50', 
'M', 
'African American', 
32); 

INSERT INTO 
Employee 

(Last_name, 
First_name, 
Address, 
City, 
State, 
Telephone_area_code, 
Telephone_number, 
Job_title, 
Hire_date, 
Wage, 
Gender, 
Race, 
Age) 

VALUES 
('Vance', 
'Brent', 
'927 Cynthia Lane Parkway', 
'Del Mar', 
'CA', 
'858', 
'555-0147', 
'Bagger - 30 hours/wk', 
'3/29/2001', 
'$6.75', 
'M', 
'Caucasian', 
22); 


------------------------------------------------------ 
/* This script inserts values into Job_title table 
** Note: 1 means exempt (salaried) 
** 0 means non-exempt (hourly) 
** Section (2.2) 
*/ 
------------------------------------------------------ 



INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Accounting Clerk', 'Office/Clerical', 
'Computes, classifies, records, and verifies numerical data for use in maintaining 
accounting records.', 
0); 

INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Assistant Manager', 'Officials & Managers', 
'Supervises and coordinates activities of workers in department of food store. 
Assists store manager in daily operations of store.' , 
1); 

INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Bagger','Sales Workers', 
'Places customer orders in bags. Performs carryout duties for customers.', 
0); 

INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Cashier','Sales Workers', 
'Operates cash register to itemize and total customer’s purchases in grocery 
store.', 
0); 

INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Computer Support Specialist','Technician', 
'Installs, modifies, and makes minor repairs to personal computer hardware and 
software systems, and provides technical assistance and training to system 
users.', 
0); 

INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Dir. of Fin. & Acct.','Officials & Managers', 
'Plans and directs the finance and accounting activities for Kudler Fine Foods.', 
1); 

INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Asst. - Bakery & Pastry','Craft Workers (Skilled)', 
'Obtains or prepares food items requested by customers in retail food store.', 
0); 

INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Asst. - Butchers & Seafood Specialists','Operatives (Semi skilled)', 
'Obtains or prepares food items requested by customers in retail food store.', 
0); 

INSERT INTO Job_title 
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status) 
VALUES 
('Stocker','Office/Clerical', 
'Stores, prices and restocks merchandise displays in store.', 
0) 





------------------------------------------------------------------------------------------ 
/* 
**(3.2) This script Checks the results by selecting 
**all of the columns from both of the tables 
**Select * from 
**Select * from 
*/ 
/* 
**Format of Employee table due to requirement 
**Do not “string out” an entire query/statement so 
**that it requires the viewer to horizontally scroll to read it. 
*/ 
------------------------------------------------------------------------------------------- 




USE Mort; 

Select Emp_id, Last_name, First_name, Address, City, State from Employee 
Go 

Select Telephone_area_code, Telephone_number, Job_title, Hire_date, Wage, Gender, Race, Age from Employee 
Go 

Select * from Job_title 
Go 

/* 
**(3.3) Write a SQL query that joins two tables in the example database and uses BETWEEN **to restrict record selection. (Use salary to restrict the data.) 
*/ 


Select Employee.Wage, Job_title.Job_title 
From Employee 
inner join Job_title 
on Employee.Wage=Job_title.Job_title 
order by Employee.Last_name 

(3.4) 예제 데이터베이스에 두 개의 테이블을 조인하고 BETWEEN을 사용하여 레코드 선택을 제한하는 SQL 쿼리를 작성하십시오. (3.5) 예제 데이터베이스의 두 테이블을 조인하고 LIKE를 사용하여 레코드 선택을 제한하는 SQL 쿼리를 작성합니다. (3.6) 예제 데이터베이스에 두 개의 테이블을 조인하고 LIKE를 사용하여 레코드 선택을 제한하는 SQL 쿼리를 작성합니다 (전화 지역 코드를 사용하여 데이터를 제한하십시오). (나이를 사용하여 20 대의 모든 사람을 찾습니다.) (3.7) 두 테이블 중 UNION을 사용하는 SQL 쿼리를 작성합니다. 창조적으로 행동하십시오.

(3.8) job_title별로 그룹화 된 평균 급여/시간당 급여를 표시하는 SQL 쿼리를 작성합니다. (3.9) 각 EE0-1 분류의 인원 수와 각 분류의 평균 급여/시간당 급여를 표시하는 SQL 쿼리를 작성하십시오. (3.10) EEO 분류별 직원 분류 : 직원의 성을 선택하고 EEO-1 분류로 분류합니다. (3.11) EEO 분류 내에서 급여별로 직원을 분류합니다. 직원의 성을 선택하고 직원의 급여로 그룹화합니다 EEO-1 분류. (3.12) 직원의 성을 선택하고 면제 및 비 면제로 그룹화 된 직위 내의 급여로 그룹화합니다. 당신은 귀하의 질문에 조금 더 나은를 포맷 한 다음 반응에 더 좋은 행운이있을 수 있습니다 어떤 관련이없는 텍스트를 잘라 경우

+4

에 대한 VALUES 섹션이 없습니다. 또한 숙제 인 경우 태그를 붙이십시오. 마지막으로 오류가 발생합니까? 그 오류가 무엇입니까? –

+1

삽입 오류가 발생하면 삽입 명령이나 문제가있는 삽입 명령으로 이어질 수있는 오류에 대해 특정 사실을 말했을 것입니다. – Leslie

답변

0

당신은 INSERT의 하나 (6 INSERT)

관련 문제