Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. USE [ConferenceLast]
  2. GO
  3.  
  4. /****** Object: StoredProcedure [dbo].[addPerson] Script Date: 21.01.2017 20:28:33 ******/
  5. SET ANSI_NULLS ON
  6. GO
  7.  
  8. SET QUOTED_IDENTIFIER ON
  9. GO
  10.  
  11.  
  12. CREATE PROCEDURE [dbo].[addEmployee]
  13. -- Add the parameters for the stored procedure here
  14. @company_id int,
  15. @name varchar(50),
  16. @title varchar(50)
  17. AS
  18. BEGIN
  19.  
  20. BEGIN TRAN
  21.  
  22. declare @CompanyAccountID int;
  23. declare @ParticipantId int;
  24.  
  25. Select @CompanyAccountID = account_id
  26. From Company
  27. where id = @company_id;
  28.  
  29. if @CompanyAccountID is not null
  30. begin
  31. insert into Participant(account_id) values (@CompanyAccountID)
  32. SET @ParticipantId = scope_identity();
  33.  
  34. insert into Employee(name, company_id,participant_id,title)
  35. values (@name, @company_id, @ParticipantId, @title)
  36. end
  37. Commit TRAN
  38.  
  39. END
  40.  
  41.  
  42.  
  43. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement