How to: Code analyze your SQL Server T-SQL scripts in Visual Studio
utterances-bot opened this issue · comments
utterances bot commented
How to: Code analyze your SQL Server T-SQL scripts in Visual Studio | ErikEJ's blog
Maybe you already take advantage of the C# code analyzers built into the .NET SDK, that help you improve code consistency, quality, security and avoid common mistakes and potential bugs.
https://erikej.github.io/dacfx/codeanalysis/sqlserver/2024/04/02/dacfx-codeanalysis.html
Stetou commented
Do you have an example of this ?
"But did you know that is is also possible to run analyzer rules against your SQL Server T-SQL object definitions (DDL)"
Let say I want to make sure that
- all my tables contains 5 technical field
- Those 5 fields are NOT NULLABLE
- All other fields are NULLABLE
I would do that in a unit test in visual studio
But, Is it something that can be done using a static code analysis ?
Erik Ejlskov Jensen commented
Have a look at the SqlServer.Rules fork that I maintain