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
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah sooo simple should have tried it. Thanks
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