A Create/Declare Table statement with a Primary Key gives a false positive BP014 in Code Analysis
If you have a table declared like this:
Declare @Test table
(TheKey int Primary Key,
SomeData varchar(10) Not Null)
I am told that for "TheKey" "[NOT] NULL option is not specified in CREATE/DECLARE TABLE statement" defined. But, a Primary Key can never be null, so it is NOT NULL by nature.
So, when performing Code Analysis and the parser sees "Primary Key", "Not Null" should be inferred also.
2
votes
![](https://secure.gravatar.com/avatar/f8cf35c378264ae0ff3b43914b544284?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
Hi,
I’m pleased to announce this issue was fixed in version 9.4.10 of SQL Prompt. You can access the latest version from https://www.red-gate.com/products/sql-development/sql-prompt/
Thank you for bringing it to our attention!
Kind Regards,
The Prompt Team