The following bit of code gives me the error message
“Incorrect syntax near the keyword 'Insert'.”
When I make changes to the code involving the From, Join and On, I get the error “Incorrect syntax near the keyword 'On'.”
--this is where this bit of code is different from the first bit
Can anyone see from this why I am getting error messages and what I can do to stop them?
TIA,
Bill
“Incorrect syntax near the keyword 'Insert'.”
Code:
If @TimeSheet_PK_ID is null or
@TimeSheet_PK_ID = 0
Begin
Select tbl_Clients_ClientBasicInfo.Client_PK_ID,
tbl_Customers_CustomerBasicInfo.Customer_PK_ID,
tbl_Jobs_JobNumber.JobNumber_PK_ID,
tbl_Jobs_JobSteps.StepNumber_PK_ID
--Tables where above PK_ID's will come from
From
tbl_Clients_ClientBasicInfo
Join
tbl_Customers_CustomerBasicInfo
Join
tbl_Jobs_JobNumber
Join
tbl_Jobs_JobSteps
ON
@ClientNumber = tbl_Clients_ClientBasicInfo.ClientNumber
and
@CustomerNumber = tbl_Customers_CustomerBasicInfo.CustomerNumber
and
@JobNumber = tbl_Jobs_JobNumber.JobNumber
and
@StepNumber = tbl_Jobs_JobSteps.StepNumber
--error pointing to Insert here
Insert into
tbl_TimeSheetEntry
(BatchNumber,
LocationNumber,
WorkDate,
Client_PK_ID,
Customer_PK_ID,
JobNumber_PK_ID,
StepNumber_PK_ID,
HoursWorked,
Units,
WagePaid,
PieceRate,
PrevailingWage,
FundingCode)
values
(@BatchNumber,
@LocationNumber,
@WorkDate,
@Client_PK_ID,
@Customer_PK_ID,
@JobNumber_PK_ID,
@StepNumber_PK_ID,
@HoursWorked,
@Units,
@WagePaid,
@PieceRate,
@PrevailingWage,
@FundingCode)
--Assign New TimeSheet_PK_ID to record just added
Set @TimeSheet_PK_ID = Scope_Identity ()
end
When I make changes to the code involving the From, Join and On, I get the error “Incorrect syntax near the keyword 'On'.”
Code:
--same as above
If @TimeSheet_PK_ID is null or
@TimeSheet_PK_ID = 0
Begin --page 274
Select tbl_Clients_ClientBasicInfo.Client_PK_ID,
tbl_Customers_CustomerBasicInfo.Customer_PK_ID,
tbl_Jobs_JobNumber.JobNumber_PK_ID,
tbl_Jobs_JobSteps.StepNumber_PK_ID
--this is where this bit of code is different from the first bit
Code:
From
tbl_Clients_ClientBasicInfo ON --error here
@ClientNumber = tbl_Clients_ClientBasicInfo.ClientNumber
Join
tbl_Customers_CustomerBasicInfo ON
@CustomerNumber = tbl_Customers_CustomerBasicInfo.CustomerNumber
Join
tbl_Jobs_JobNumber ON
@JobNumber = tbl_Jobs_JobNumber.JobNumber
Join
tbl_Jobs_JobSteps ON
@StepNumber = tbl_Jobs_JobSteps.StepNumber
Insert into
tbl_TimeSheetEntry
(BatchNumber,
LocationNumber,
WorkDate,
Client_PK_ID,
Customer_PK_ID,
JobNumber_PK_ID,
StepNumber_PK_ID,
HoursWorked,
Units,
WagePaid,
PieceRate,
PrevailingWage,
FundingCode)
values
(@BatchNumber,
@LocationNumber,
@WorkDate,
@Client_PK_ID,
@Customer_PK_ID,
@JobNumber_PK_ID,
@StepNumber_PK_ID,
@HoursWorked,
@Units,
@WagePaid,
@PieceRate,
@PrevailingWage,
@FundingCode)
--Assign New TimeSheet_PK_ID to record just added
Set @TimeSheet_PK_ID = Scope_Identity ()
end
Can anyone see from this why I am getting error messages and what I can do to stop them?
TIA,
Bill