หาก Run ทั้งหมดจะเกิด Error เกี่ยวกับ Data Type เข้าใจว่าบางฟังก์ชั่นให้ผลเป็นค่าผิดพลาดหรือ Null กับบาง Filed ผมลอง Union แค่ Top 5 , Top 100, Top 1000 สามารถทำงานได้ปกติครับ
Code: Select all
SELECT Top 5 [PID_SELECT],[PID_SELECT_FNAME],[PID_SELECT_MNAME],[PID_SELECT_LNAME],[PID_SELECT_SEX],[PID_SELECT_BIRTHDATE],[PID_SELECT_NATION]
,[PID_SELECT_RELIGION],[WORK_START_DATE],[POSITION_REGISTER_ID],[RELATION],[PID],[PID_FNAME],[PID_MNAME],[PID_LNAME],[PID_SEX],[PID_BIRTHDAY]
,[PID_NATION],[PID_RELIGION],[Child_Incompletent],[CHILD_REGULARITY]
from 1_Personal1
UNION ALL
SELECT Top 5 [PID_SELECT],[PID_SELECT_FNAME],[PID_SELECT_MNAME],[PID_SELECT_LNAME],[PID_SELECT_SEX],[PID_SELECT_BIRTHDATE],[PID_SELECT_NATION]
,[PID_SELECT_RELIGION],[WORK_START_DATE],[POSITION_REGISTER_ID],[RELATION],[PID],[PID_FNAME],[PID_MNAME],[PID_LNAME],[PID_SEX],[PID_BIRTHDAY]
,[PID_NATION],[PID_RELIGION],[Child_Incompletent],[CHILD_REGULARITY]
from 2_Employee
UNION ALL
SELECT Top 5 [PID_SELECT],[PID_SELECT_FNAME],[PID_SELECT_MNAME],[PID_SELECT_LNAME],[PID_SELECT_SEX],[PID_SELECT_BIRTHDATE],[PID_SELECT_NATION]
,[PID_SELECT_RELIGION],[WORK_START_DATE],[POSITION_REGISTER_ID],[RELATION],[PID],[PID_FNAME],[PID_MNAME],[PID_LNAME],[PID_SEX],[PID_BIRTHDATE]
,[PID_NATION],[PID_RELIGION],[Child_Incompetent],[CHILD_REGULARITY]
from 3_Couple_Personal
UNION ALL
SELECT Top 5 [PID_SELECT],[PID_SELECT_FNAME],[PID_SELECT_MNAME],[PID_SELECT_LNAME],[PID_SELECT_SEX],[PID_SELECT_BIRTHDATE],[PID_SELECT_NATION]
,[PID_SELECT_RELIGION],[WORK_START_DATE],[POSITION_REGISTER_ID],[RELATION],[PID],[PID_FNAME],[PID_MNAME],[PID_LNAME],[PID_SEX],[PID_BIRTHDATE]
,[PID_NATION],[PID_RELIGION],[Child_Incompetent],[CHILD_REGULARITY]
from 4_Couple_Employee
UNION ALL
SELECT Top 5 [PID_SELECT],[PID_SELECT_FNAME],[PID_SELECT_MNAME],[PID_SELECT_LNAME],[PID_SELECT_SEX],[PID_SELECT_BIRTHDATE],[PID_SELECT_NATION]
,[PID_SELECT_RELIGION],[WORK_START_DATE],[POSITION_REGISTER_ID],[RELATION],[PID],[PID_FNAME],[PID_MNAME],[PID_LNAME],[PID_SEX],[PID_BIRTHDATE]
,[PID_NATION],[PID_RELIGION],[Child_Incompetent],[CHILD_REGULARITY]
from 5_Parent_Personal_DAD
UNION ALL
SELECT Top 5 [PID_SELECT],[PID_SELECT_FNAME],[PID_SELECT_MNAME],[PID_SELECT_LNAME],[PID_SELECT_SEX],[PID_SELECT_BIRTHDATE],[PID_SELECT_NATION]
,[PID_SELECT_RELIGION],[WORK_START_DATE],[POSITION_REGISTER_ID],[RELATION],[PID],[PID_FNAME],[PID_MNAME],[PID_LNAME],[PID_SEX],[PID_BIRTHDATE]
,[PID_NATION],[PID_RELIGION],[Child_Incompetent],[CHILD_REGULARITY]
from 6_Parent_Personal_MOM;
UNION ALL
SELECT Top 5 [PID_SELECT],[PID_SELECT_FNAME],[PID_SELECT_MNAME],[PID_SELECT_LNAME],[PID_SELECT_SEX],[PID_SELECT_BIRTHDATE],[PID_SELECT_NATION]
,[PID_SELECT_RELIGION],[WORK_START_DATE],[POSITION_REGISTER_ID],[RELATION],[PID],[PID_FNAME],[PID_MNAME],[PID_LNAME],[PID_SEX],[PID_BIRTHDATE]
,[PID_NATION],[PID_RELIGION],[Child_Incompetent],[CHILD_REGULARITY]
from 7_Child_Personal;
UNION ALL
SELECT Top 5 [PID_SELECT],[PID_SELECT_FNAME],[PID_SELECT_MNAME],[PID_SELECT_LNAME],[PID_SELECT_SEX],[PID_SELECT_BIRTHDATE],[PID_SELECT_NATION]
,[PID_SELECT_RELIGION],[WORK_START_DATE],[POSITION_REGISTER_ID],[RELATION],[PID],[PID_FNAME],[PID_MNAME],[PID_LNAME],[PID_SEX],[PID_BIRTHDATE]
,[PID_NATION],[PID_RELIGION],[Child_Incompetent],[CHILD_REGULARITY]
from 8_Child_Employee;