

CREATE PROCEDURE [dbo].[API_CreateOperatorErp]
	@operatorId AS INT
AS 
BEGIN

SET IDENTITY_INSERT [dbo].[ApiWorkers] ON;

INSERT INTO [dbo].[ApiWorkers]
           (Id,[Name],[Surname],[Passwd],[GroupId],[Priviliges],[lang],[Currency],[RepositoryId],[WorkTime]
           ,[Permissions],[Position],[SuperiorId],[WorkFrom],CustId,[EmailAdress],[ImapServer],[ImapUser],
		   [ImapPassword],[ImapPort]
		   ,ImapSSL, [SmtpServer],[SmtpUser],[SmtpPassword], SmtpPort,SmtpSSL, 
		   [CheckMailBox],[ModelWorkerId],[EmaiTaskDefId],[SendEmailNotyfications]
		    ,[ErpId]
	,[CardNumber]
	,[WorkerId] 
	,[DepartamentId],[ErpId]
	,[CardNumber]
	,[WorkerId] 
	,[DepartamentId]
		   )    
           select Id
      ,[Name]
      ,[Surname]
      ,[Passwd]
      ,[GroupId]
      ,[Priviliges]
      ,[lang]
      ,[Currency]
      ,[RepositoryId]
      ,[WorkTime]
      ,[Permissions]
      ,[Position]
      ,[SuperiorId]
      ,[WorkFrom]
      ,[CustId]
      ,[EmailAdress]
      ,[ImapServer]
      ,[ImapUser]
      ,[ImapPassword]
      ,[ImapPort]
      ,[ImapSSL]
      ,[SmtpServer]
      ,[SmtpUser]
      ,[SmtpPassword]
      ,[SmtpPort]
      ,[SmtpSSL]
      ,[CheckMailBox]
      ,[ModelWorkerId]
      ,[EmaiTaskDefId]
      ,[SendEmailNotyfications]
	  ,[ErpId]
	,[CardNumber]
	,[WorkerId] 
	,[DepartamentId]
	  
	  from dbo.ApiWorkersPHView  where Id =@operatorId;
		   

     


SET IDENTITY_INSERT [dbo].[ApiWorkers] OFF;
END


