-1
我有一個錯誤,我找不到此過程失敗的原因。我只知道它做了一些我不知道的事情。有沒有人有一個想法是什麼? :|更新存儲過程 - SQL Server 2012
ALTER PROCEDURE [dbo].[updateAccountPersonJob]
@department nvarchar(50),
@description nvarchar(50),
@personID int,
@name nvarchar(50),
@surname nvarchar(50),
@email nvarchar(50),
@username nvarchar(50),
@password nvarchar(50),
@status nvarchar(50)
AS
BEGIN TRANSACTION
DECLARE @missionID int, @jobID int;
BEGIN TRY
SET @jobID = (SELECT id FROM Jobs
WHERE department = @department AND description = @description)
UPDATE Persons
SET name = @name, surname = @surname, email = @email, jobID = @jobID
WHERE Persons.id = @personID
UPDATE Accounts
SET Username = @username, Password = @password, Status = @status
WHERE Accounts.Password = @personID
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;
BEGIN IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;
PRINT('ROLLBACK')
END
END CATCH;
IF @@TRANCOUNT > 0
COMMIT TRANSACTION;
EXEC:
EXEC [dbo].updateAccountPersonJob
@department = N'Facultatea de Matematica si Informatica',
@description = N'Teacher',
@personID = N'16',
@name = N'Dummy',
@surname = N'BarFOO',
@email = N'[email protected]',
@username = N'dummy',
@password = N'd',
@status = N'Teacher'
錯誤:
Conversion failed when converting the nvarchar value 'director' to data type int.
如果運行'SELECT ID喬布斯WHERE部門= @department和描述= @ description'您能得到什麼結果? – Taryn
打印了一個有效的ID –
你可以用兩個表的表結構來編輯你的問題嗎?你在桌上有沒有觸發器? – Taryn