Вопрос

Я использую скрипт вставки, который должен вставить 13,381 строки в пустую БД из SSMS. Он рассказывает мой «запрос в комплекте с ошибками» и только вставляется 13357 строк.

Ничто не отображается в списке ошибок. Как я могу найти ошибки в сценарии?

Спасибо!

Это было полезно?

Решение

попробуй это:

begin try

    --your inserts here

end try
begin catch
    --returns the complete original error message as a result set
    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

    --will return the complete original error message as an error message
    DECLARE @ErrorMessage nvarchar(400), @ErrorNumber int, @ErrorSeverity int, @ErrorState int, @ErrorLine int
    SELECT @ErrorMessage = N'Error %d, Line %d, Message: '+ERROR_MESSAGE(),@ErrorNumber = ERROR_NUMBER(),@ErrorSeverity = ERROR_SEVERITY(),@ErrorState = ERROR_STATE(),@ErrorLine = ERROR_LINE()
    RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState, @ErrorNumber,@ErrorLine)
end catch
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top