Link to home
Start Free TrialLog in
Avatar of jui2ce
jui2ce

asked on

Stored Procedure to move records

I have a stored procedure that just moves contacts from one table to another. It looks like this.

CREATE PROCEDURE sp_MoveContacts
(
      @ID      int,
                @companyID int
)
AS

INSERT Contacts ( FirstName,LastName, ContactTypeID, companyID )
SELECT FirstName, LastName, ContactTypeID ,companyID
FROM
      v_CartContactInfo
WHERE
      ID=@ID
GO

Instead of it copying the ComanyID from one table to another. I would like to put the companyID that I pass to the stored procedure
Instead ove
Avatar of mokule
mokule
Flag of Poland image

BEGIN TRAN

INSERT Contacts ( FirstName,LastName, ContactTypeID, companyID )
SELECT FirstName, LastName, ContactTypeID ,companyID
FROM
     v_CartContactInfo
WHERE
     ID=@ID

DELETE
FROM
     v_CartContactInfo
WHERE
     ID=@ID

COMMIT TRAN
Avatar of jui2ce
jui2ce

ASKER

I don't see where this would insert into the new Table the CompanyId I pas instead of just coping the one in the current table.
ASKER CERTIFIED SOLUTION
Avatar of rafrancisco
rafrancisco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jui2ce

ASKER

Ah sooo simple should have tried it. Thanks