0

I implemented audit in SQL Server 2019. Also I have created a job to save audit records from file to a table. According the microsoft document column class_type is NOT NULL. so in my table is NOT NULL too. But today my job failed with the following error message:

Cannot insert the value NULL into column 'class_type',

First of all I think this is my fault and the query has problem. Then I discovered that really the function sys.fn_get_audit_file returns NULL for three statement that are GRANT PERMISSION.

Although I can filter these three transaction to continue saving audit record. But this conflict between Microsoft documentation and actual data makes me anxious.

Edit: Additional information is that the execution of these statements completed with errors. Because the object names were incorrect.

4
  • 3
    If you’re having a problem with a query you should post the query you’re having a problem with. Commented Jul 30, 2023 at 13:24
  • 2
    sp_describe_first_result_set returns is_nullable: 1 for that column, so probably the docs are wrong. Some of the other columns also don't seem to match. But we'd need to see your query to be sure it's not something there. Commented Jul 30, 2023 at 20:03
  • @Charlieface My query is a simple SELECT statement from sys.fn_get_audit_file Commented Jul 31, 2023 at 11:28
  • @ErikDarling SELECT * FROM sys.fn_get_audit_file (params) Where class_type is null -- This will return 3 records Commented Jul 31, 2023 at 11:30

1 Answer 1

1

sp_describe_first_result_set returns is_nullable: 1 for that column, so presumably the documentation is wrong. Some of the other columns also don't seem to match.

You can make a pull request on GitHub here to change the docs.

Exactly why it's returning null, or what the meaning of that should be, is unclear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.