1

Hello I'm trying to create a stored procedure to quickly add contacts. I have multiple tables and joined them accordingly. My parameters are StudentEmail,EmployeeName,ContactDetails, and ContactType. I'm having trouble with my insert into statement if anyone can help me out.

 Drop Procedure if exists usp_addQuickContacts
 Go
 Create Procedure usp_addQuickContacts
   @StudentEmail nchar(50) = NULL, 
   @EmployeeName nchar (50) = NULL, 
   @ContactDetails nchar (50) = NULL, 
   @ContactType nchar(50)  = NULL

AS
Begin
Insert Into StudentContacts
(
    ContactID,
    StudentID,
    ContactTypeID,
    ContactDate,
    EmployeeID,
    ContactDetails
            )
 From StudentInformation inner join StudentContacts 
 On StudentInformation.StudentID = StudentContacts.StudentID 
 Inner Join Employees 
 On StudentContacts.EmployeeID = Employees.EmployeeID

End
Go
Vt1818
  • 11
  • 2

1 Answers1

1

Your subquery is missing a select:

Insert Into StudentContacts (ContactID, StudentID, ContactTypeID, ContactDate, EmployeeID, ContactDetails)
    select . . . 
    From StudentInformation si inner join
         StudentContacts sc
         On si.StudentID = sc.StudentID inner join
         Employees e
         On sc.EmployeeID = e.EmployeeID;

The . . . is for the columns, presumably from the underlying tables. You need to fill in that part.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786