How do you guys use Claude (or similar AI) to interact with your MSSQL database?
Hey everyone, I'm working on a .NET 4.6 project with Entity Framework and an MSSQL Server database that's getting pretty complex. We have a bunch of stored procedures that I suspect could use some optimization work, but I'm looking for a better workflow to actually make that happen.
Here's my situation:
- I have a legacy .NET 4.6 project with EF and a connection string in the config
- Database has a decent schema with multiple tables and some SPs that are getting slower
- I've tried using Claude Code to interact with the DB directly, but it can't actually execute queries since it's sandboxed
What I'm trying to achieve: I want to give Claude actual read/execute access to my database so it can:
- Analyze the current schema and business logic
- Write and test optimized queries
- Actually run the queries and compare execution times
- Understand the business logic from both the database structure and my C# project
- Come back with recommendations or even write the optimized code
My current plan: Use SQLCMD to let Claude execute queries directly against my database, but I'm wondering:
- How are you guys using Claude or LLM for database work? Are you just sharing schema dumps and asking for optimization tips or do you have something more integrated?
- What other tools do you use for this kind of DB operations?
- Have you had success with AI actually optimizing your queries? Or is it more of a "get suggestions and test manually" kind of thing?
I'm open to other approaches too – whether it's exporting execution plans, schema documentation or something else entirely. Just looking for a workflow that actually works in practice.
Appreciate any insights! 🙌