How to insert values ​​using Joins in asp.net stored procedure?

 CREATE PROCEDURE [dbo].[K_HRM_Insert_VehicleAssign]
     @vehiclename varchar(50),
     @empname varchar(50),
     @updatedby varchar(50),
     @updatedon datetime
 AS 
 BEGIN
     INSERT INTO K_MasterEmpDetails ME 
     INNER JOIN K_HRM_Vehicle_Assign VA ON VA.[empname+id] = ME.Firstname +' '+ME.Lastname + ' - ' + ME.kjlid AS ME.Employee
     (VA.vehiclename, ME.Employee, VA.updatedby, VA.updatedon)
     VALUES (@vehiclename, @empname, @updatedby, GETDATE())
 END

I get an error next to ME... please help me

+4
source share
2 answers

You cannot use this syntax. The correct syntax is:

INSERT INTO Table
(COLUMNS)
VALUES
(value)

To correctly insert into two tables, you must use a transaction and insert it into two tables separately.

+2
source

You are syntactically mistaken. The correct syntax is what the user said is basic but you can use

Insert into Table 
select statement 

It will select rows based on the condition, and then insert into the table. and in select statement you can use join.

0

All Articles