I need to write a stored procedure which should take CustomerID
as a parameter and return Name
from atbv_Contacts
, where the parameter of ContactID
column is the same as CustomerID
.
My problem is that I guess I'm only trying to get ID, therefore it won't show me the Customer's ID. Plus I don't think that this procedure is written correctly as I get the following errors:
Msg 3609, Level 16, State 2, Procedure atsp_GetNameID, Line 7
The transaction ended in the trigger. The batch has been aborted.Msg 50000, Level 18, State 1, Procedure strg_Database_ChangeLog, Line 90
Invalid object name. Please check for a typo.
My current code:
CREATE PROCEDURE atsp_GetNameID
(@CustomerID AS INT)
AS
BEGIN
SELECT ContactID
FROM atbv_Contacts
WHERE ContactID LIKE '%' + @CustomerID + '%'
END
Replace with this
CREATE PROCEDURE atsp_GetNameID
(@CustomerID AS INT)
AS
BEGIN
SELECT ContactID
FROM atbv_Contacts
WHERE ContactID =@CustomerID
END
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.