好的我已經搜索了一個答案,但沒有找到它,也許我只是沒有輸入正確的問題,所以這裏什麼都不做。我有2個表,我的兩個表都有一個自動生成的PK。表2中的PK是表1中的FK。由於它們都是自動生成的,因此我假定表1中的FK將填充表2中自動生成的值,但它不起作用。表1中的FK顯示爲空。以下是創建表1我的SQL代碼:外鍵不填充主鍵值
CREATE TABLE Employee_tbl (
EmployeeID int PRIMARY KEY IDENTITY,
LastName varchar(20) not null,
FirstName varchar(20) not null,
[Address] varchar(60)not null,
City varchar(20) not null,
[State] varchar(20) not null,
TelephoneAreaCode varchar(3) not null,
TelephoneNumber varchar(7) not null,
HireDate date,
Salary varchar(20) not null,
Gender char(1) not null,
Age varchar(3) not null,
JobID int FOREIGN KEY REFERENCES JobTitle_tbl(JobID),
)
這裏是表2:
create table JobTitle_tbl(
JobID int PRIMARY KEY IDENTITY,
EEO1Classification varchar(50) not null,
Job_title varchar(50) not null,
Job_description varchar(MAX) not null,
Exempt_nonexempt_status varchar(20) not null,
)
我也有一些插入語句:
INSERT INTO Employee_tbl (LastName, FirstName, [Address], City, [State], TelephoneAreaCode,
TelephoneNumber, HireDate, Salary, Gender, Age)
Values
('Smith', 'John', '1234 Number Lane', 'Los Angeles', 'California', '555',
'8675309', '10/07/2003', '20,000.00', 'M', '50'),
...
和:
INSERT into JobTitle_tbl (EEO1Classification, Job_title, Job_description, Exempt_nonexempt_status)
VALUES
('Office/Clerical', 'Accounting Clerk', 'Computes classifies records and verifies numerical data for use in maintaining
accounting records. Essential Duties
1. Compiles and sorts documents, such as invoices and checks,
substantiating business transactions.
2. Verifies and posts details of business transactions, such as funds received
and disbursed, and totals accounts to ledgers or computer spreadsheets
and databases.
3. Audits invoices against purchase orders, researches discrepancies, and
approves for payment.
4. Computes and records charges, refunds, cost of lost or damaged goods,
freight charges, rentals and similar items.
5. Prepares vouchers, invoices, checks, account statements, reports and
other records and reviews for accuracy.
6. Reconciles general ledger accounts with various registers.
7. Reconciles bank statements.
8. Monitors accounts payable and receivable to ensure that payments are up
to date.
9. Assists employees, vendors, clients, or customers by answering questions
related to accounts, procedures, and services.
Required Qualifications and Experience
The accounting clerk must have excellent math and accounting skills, in addition
to the ability to use Quick Books software for maintaining records.', 'Non-Exempt'),
爲什麼FK值顯示爲空當我查詢表1?
請問您可以減少問題中的措詞嗎?另外FK不是自動生成的。你將不得不明確插入子表 – 2012-01-28 16:42:19