Schaeffrcc
Technical User
I have been working on this problem my company has to move data from one database to another. I have a Query that I set up in Access to query out all of the data element and update another table. I grabbed the SQL script data and tried to fix it so I could run it in Query Analyzer.
Generally:
I have 5 Tables:
Agent
Client_Agent_link
Client
Case_Table
Case_History
Case_table is where most of the data comes from and it Right joins to Case_history and it Left Joins to Client
Client Left Joins to Client_agent_Link
Client_Agent_Link Left Joins to Agent
Agent <- Client_Agent_Link <- Client <- Case_Table -> Case_History.
I hope that makes Sense?
Here is what I have for my Script:
/* insert new rows */
INSERT INTO CaseFee
SELECT case_table.case_seq,
case_table.client_seq,
case_history.case_type_seq,
case_table.offense_type_seq,
agent.agent_seq,
case_table.case_offense_date,
case_history.case_open_date,
case_history.case_close_date,
case_table.case_number,
case_table.case_sentence_date,
case_table.case_exp_date,
case_table.case_desc,
case_table.case_adult_juv
FROM case_table
RIGHT JOIN Case_history ON case_history.case_seq = case_table.case_seq
LEFT JOIN Client ON client.client_seq = Case_Table.client_seq
Left Join Client_Agent_link ON Client_agent_link.client_seq = Client.client_seq
LEFT Join client_agent_link.agent_seq = agent.agent_seq
WHERE case_history.case_type_seq = 2 Or
case_history.case_type_seq = 6 Or
case_history.case_type_seq = 23 Or
case_history.case_type_seq = 9 Or
case_history.case_type_seq = 13 Or
case_history.case_type_seq = 14 AND
case_history.case_open_date >= #5/1/2003# AND
client_agent_link.ca_link_to_date Is Null AND
agent.agent_initials<>"SCL" And
agent.agent_initials Not Like "0*" and
CaseFee.Case_seq IS NULL
I have not even gotten to the Problems that I am sure are in the Where Statement.
Please Help, My Brain is Fried and it is Friday after all.
Thomas
Generally:
I have 5 Tables:
Agent
Client_Agent_link
Client
Case_Table
Case_History
Case_table is where most of the data comes from and it Right joins to Case_history and it Left Joins to Client
Client Left Joins to Client_agent_Link
Client_Agent_Link Left Joins to Agent
Agent <- Client_Agent_Link <- Client <- Case_Table -> Case_History.
I hope that makes Sense?
Here is what I have for my Script:
/* insert new rows */
INSERT INTO CaseFee
SELECT case_table.case_seq,
case_table.client_seq,
case_history.case_type_seq,
case_table.offense_type_seq,
agent.agent_seq,
case_table.case_offense_date,
case_history.case_open_date,
case_history.case_close_date,
case_table.case_number,
case_table.case_sentence_date,
case_table.case_exp_date,
case_table.case_desc,
case_table.case_adult_juv
FROM case_table
RIGHT JOIN Case_history ON case_history.case_seq = case_table.case_seq
LEFT JOIN Client ON client.client_seq = Case_Table.client_seq
Left Join Client_Agent_link ON Client_agent_link.client_seq = Client.client_seq
LEFT Join client_agent_link.agent_seq = agent.agent_seq
WHERE case_history.case_type_seq = 2 Or
case_history.case_type_seq = 6 Or
case_history.case_type_seq = 23 Or
case_history.case_type_seq = 9 Or
case_history.case_type_seq = 13 Or
case_history.case_type_seq = 14 AND
case_history.case_open_date >= #5/1/2003# AND
client_agent_link.ca_link_to_date Is Null AND
agent.agent_initials<>"SCL" And
agent.agent_initials Not Like "0*" and
CaseFee.Case_seq IS NULL
I have not even gotten to the Problems that I am sure are in the Where Statement.
Please Help, My Brain is Fried and it is Friday after all.
Thomas