How to Help Copilot Encourage Good Database Standards
12 Comments
I know a lot of y’all lag behind on upgrading SSMS, but v22.3 just introduced something that you need to be aware of. It’s going to impact any of your users who DO upgrade their SSMS, or who use Github Copilot. There’s something that you can do in order to improve Copilot’s code quality and make it match your preferred coding standards.
You can add database instructions as extended properties at the database or object level, and when Copilot works with those objects, it’ll read your instructions and use them to shape its advice.
For example, you can add a database-level property called a “constitution” with your company’s coding standards, like this:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
EXECUTE sp_addextendedproperty @name = N'CONSTITUTION.md', @value = N'Any objects and T-SQL in this database must comply with the organizational standards and guidelines outlined in this constitution document. ## Object Naming Standards Views must always be prefixed with vw_. Tables should never be prefixed with tbl_. Table and column names should be in camel case with a capitalized first letter, like UserProperties or SalesByMonth. Index names should be based on the key columns in the index. If the index has include columns, add an _inc suffix to the index name. Index names should never be prefixed with table names, idx_, ix_, or any variation thereof. ## Query Standards Queries should be written in a concise, easy-to-understand, performant way. Queries should prefer CTEs over temp tables unless that presents a performance issue for the query.'; |
Neato, huh? You can also define guidance at the object level:
|
1 2 3 4 5 6 7 8 |
EXECUTE sp_addextendedproperty @name = N'AGENTS.md', @value = N'The Views column represents the number of times other people have viewed this user profile. The AboutMe column is an NVARCHAR(MAX), but only 4000 characters of content should be allowed for inserts and updates.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Users'; |
Then, when SSMS Copilot or Github Copilot query the database schema to understand it, they’ll automatically read the Constitution.md and Agents.md properties, and take that into account when generating code for you. (It doesn’t work quite right just yet – you have to manually prompt it to go read the advice in v22.3 – but it’s clear that Microsoft intends it to work automatically without being reminded.)
That’s brilliant and I love it!
In a perfect world, this is going to let us define database & coding standards, check them into source control as part of our database schema, and when developers ask Copilot for code reviews or to write new queries & tables, our teams will actually get meaningful advice!
But at the same time, it poses a risk. If anyone adds extended properties to your databases, they can shape the advice you get from AI. That means it’s up to you, dear reader, to spearhead the drive for good coding standards in your databases, and make sure other people don’t steer the code in the wrong direction.
Here’s how to see what AI advice constraints have been set up in a database:
|
1 2 3 4 5 |
SELECT class, class_desc, OBJECT_NAME(major_id) AS object_name, name, value FROM sys.extended_properties WHERE name IN ('AGENTS.md', 'CONSTITUTION.md') ORDER BY class, class_desc, OBJECT_NAME(major_id); |
We’ve also added CONSTITUTION.md support to the First Responder Kit in the dev branch if you’d like to get a sneak peek before the May 2026 release. Our free health check script, sp_Blitz, warns you if someone’s added AI guidance at the database or object level, and sp_BlitzCache adds the CONSTITUTION.md guidance when building AI prompts for you, so your code standards are followed by ChatGPT.













If your company is hiring, leave a comment. The rules:





Everybody in tech has private equity stories, some good, some terribad. Private equity hands money to companies not out of generosity, but because they believe they can turn it into even more money over time. The new PE owners want to pump up the company’s revenues, cut expenses, and raise profits as quickly as possible. That way, better numbers help them turn around and offer the company’s stock to the public, getting their money back out plus a nice profit.










It’s a really slippery slope, and it goes downhill fast.

