Question

Je suis en cours d'exécution d'un script d'insertion qui est censé insérer 13,381 lignes dans une base de données vide de SSMS. Son dire mon « Requête terminée avec des erreurs » et insère seulement 13357 lignes.

Rien n'apparaît dans la liste des erreurs. Comment puis-je trouver les erreurs dans le script?

Merci!

Était-ce utile?

La solution

essayez ceci:

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top