john kanyora

john kanyora

  • NA
  • 242
  • 44.6k

how to insert data from one table to another

Feb 27 2018 1:23 AM
Hi, kindly seeking for help on how i can use a stored procedure to select data from one table and insert into another..i have the below stored procedure..kindly help on how i implement it to achieve inserting data from one table to another.
  1. CREATE PROCEDURE [enterprise].[send_sms]  
  2. (  
  3. @CompanyID NVARCHAR(72),  
  4. @BranchID NVARCHAR(36),  
  5. @DepartmentID NVARCHAR(36),  
  6.   
  7. @Value nvarchar(36)=''  
  8. )  
  9. AS  
  10. DECLARE @EmployeeName nvarchar(36)  
  11. DECLARE @EmployeeMobilePhone nvarchar(36)  
  12. DECLARE @VendorName nvarchar(36)  
  13. DECLARE @VendorPhone nvarchar(36)  
  14. DECLARE @PatientName nvarchar(36)  
  15. DECLARE @PatientCellPhone nvarchar(36)  
  16. BEGIN  
  17. IF @Value='Patients'  
  18. BEGIN  
  19. select PatientName,PatientCellPhone from CustomerInformation  
  20. END  
  21. ELSE IF @Value='Suppliers'  
  22. BEGIN  
  23. select VendorName,VendorPhone from VendorInformation  
  24. END  
  25. ELSE IF @Value='Employees'  
  26. BEGIN  
  27. select EmployeeName,EmployeeMobilePhone from PayrollEmployees  
  28. END  
  29. END  

Answers (11)