Copying some columns from one table to another while also adding user input values

Clash Royale CLAN TAG#URR8PPPCopying some columns from one table to another while also adding user input values
I have two tables, Table 1 and Table 2. Table 2 contains the exact same columns as table 1 with five additional columns. Table 1 contains basic employee information, and table 2 contains a history of every time the employee is not at work.
Through a VBA built program, the user can mark an employee as absent and then supply a type of absence, an exception can be granted, and then a reason for the exception. Whenever an absence is created, I want to copy the employee info from table 1, insert it into table 2 along with the type of absence, exception, and exception reason.
I know how to copy the information from table 1 to table 2, but how can I do that and insert the new values from the user input?
INSERT INTO Table 2(
FirstName,
LastName,
AgentName,
Location,
EmployeeGroup,
ContractAgency,
Manager,
Supervisor,
Team,
Title,
Position,
StaffCIMID,
FTPT,
Bilingual,
Five9Email,
Email,
WeekdaySchedule,
WeekendSchedule,
CreatedBy,
CreatedDate,
ModifiedBy,
ModifiedDate,
Notseatedreason,
Exception,
Exceptionreason
)
SELECT (
FirstName,
LastName,
AgentName,
Location,
EmployeeGroup,
ContractAgency,
Manager,
Supervisor,
Team,
Title,
Position,
StaffCIMID,
FTPT,
Bilingual,
Five9Email,
Email,
WeekdaySchedule,
WeekendSchedule
)
FROM Table 1
WHERE AgentName = 'userselectedvalue'
CreatedBy,CreatedDate,Notseatedreason,Exception,Exceptionreason
are the additional colums on Table 2 that need to be filled based on user input. Createdby just captures the AD username, createddate just grabs the system time, notseatedreason is a VBA form user input, Exception is a VBA userform bit based on a checkbox, Exceptionreason is a VBA userform input.
CreatedBy,CreatedDate,Notseatedreason,Exception,Exceptionreason
1 Answer
1
You can do :
insert into table2 (col1, col2, col3, col4, . . .)
select col1, col2, @inpuvalue1, @inputvalue2, . . .
from table1 t1
where . . .;
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.