⚡ Key Takeaways
- Brent Ozar utilized Claude Code and ChatGPT Codex to build a fully playable multi-player game inside SQL Server.
- The entire game operates inside an Azure SQL Database using a single stored procedure named
sp_TexasHoldEm. - Security issues were discovered where players could query global temp tables to spy on opponents’ cards and cheat.
- The project represents a massive shift in how database developers view AI-driven code generation and testing.
You might think your database is only good for storing boring financial transactions, but the invention of SQL Poker proves otherwise. Through a groundbreaking project known as sp_TexasHoldEm, database pioneer Brent Ozar recently demonstrated that a fully functional, multi-player Texas Hold ‘Em game can run entirely within a Microsoft SQL Server instance. This incredible feat of database engineering did not rely on complex external application servers or massive codebase repositories.
With SQL Poker, database administrators can now enjoy high-stakes gameplay without leaving their query windows. This is not just a simple toy or a single-player simulation against a random number generator. It is a live, interactive, multiplayer environment where human players and database-driven AI robots battle for “Query Bucks” in real-time. This project pushes the absolute limits of Transact-SQL, showing what happens when developer curiosity meets cutting-edge generative technology.
By utilizing modern serverless cloud environments, players from around the world can connect and play against each other using standard database queries. It opens up an entirely new paradigm for interactive database experimentation. Developers can inspect transaction execution times while simultaneously raising their bets.
How SQL Poker Redefines Database Capabilities

The development of SQL Poker demonstrates that relational engines can process complex state machines. Typically, database procedures handle quick CRUD operations or mathematical aggregations rather than real-time interactive loops. However, the creation of this game proves that the boundaries of Transact-SQL are far wider than most enterprise developers realize. It challenges our fundamental understanding of database session state management by implementing a multiplayer lobby directly inside system memory.
The core engine of this project runs via a single stored procedure called sp_TexasHoldEm. When a player executes this procedure in SQL Server Management Studio (SSMS), the database assigns them a seat at a virtual eight-player table. If there are not enough human participants online, the system dynamically spawns automated robot players to fill the remaining spots. This creates an incredibly dynamic environment that responds instantly to user inputs and session changes.
This entire setup operates seamlessly in Azure SQL Database Serverless, allowing the system to scale down to zero when idle. By connecting directly to a public server on port 1433, anyone with a database client can pull up a chair and start betting. The interactive loop keeps your session open until it is your turn, prompting you with specific command lines to execute your next move. It is a brilliant utilization of serverless technology to minimize hosting costs while maintaining global accessibility.
When you run a game of SQL Poker, the database handles all player interactions seamlessly. This architecture relies on global temporary tables in the tempdb database to track active hands, chip counts, and card decks. While traditional software development utilizes web sockets or specialized API layers, this system streams live game updates directly to the SSMS Messages tab. It represents an ingenious hack that turns a database administration tool into a fully functional gaming console.
Inside Storing and State Management
To understand how this system maintains state, we must look at how SQL Server handles temporary objects. Global temporary tables are visible to all sessions, making them ideal for sharing game state across different connections. However, managing concurrency in these tables requires precise transaction isolation levels to prevent race conditions. The AI agents had to implement complex locking strategies to ensure that no two players could draw the same card from the virtual deck simultaneously. This level of technical complexity highlights the incredible planning that went into the automated codebase.
Furthermore, the database must track player status even if their connection drops. To solve this, the stored procedure requires a combination of a seat password and a player name. If a developer accidentally disconnects, they can easily resume their seat by passing these parameters back into the stored procedure. This ensures that the state machine remains resilient, allowing players to rejoin the action without losing their chip stacks or their active hands.
Expert Take: According to database architecture veterans, running game state machines inside SQL Server is highly inefficient for production but acts as the ultimate stress test for locking, blocking, and transaction isolation levels. In database systems, concurrency is usually managed to prevent dirty reads and write conflicts. In a card game, however, concurrency is the game itself, requiring meticulous locking strategies to ensure no two players draw the exact same card from the virtual deck simultaneously. This forces developers to master advanced database tuning concepts that are highly applicable to real-world enterprise architectures.
Comparing Claude and ChatGPT Architectures
The comparison between the two AI-generated versions of SQL Poker reveals fascinating software design patterns. Analyzing the code produced by these competing artificial intelligence models reveals stark differences in design philosophy and implementation style. While both systems ultimately generated a playable game, their approaches to user experience and stability diverged significantly. Developers found that one model prioritized smooth interaction while the other focused on robust programmatic rules.
The version of SQL Poker developed by Claude Code excelled in player immersion and real-time interaction. It utilized active wait states to pause the user’s SSMS session until other players made their moves. This created a flow that mirrored a real-world poker table, keeping players engaged without requiring them to constantly poll the database manually. It made the entire experience feel like a real game rather than a series of disconnected batch queries.
Conversely, the ChatGPT Codex version provided superior analytical player logic and a highly robust betting system. It made the implementation of the “all-in” mechanic incredibly smooth and managed chip stacks with mathematical precision. To build the ultimate version of the game, developers ended up merging the best elements of both codebases into a single, cohesive procedure. This hybrid approach yielded a game that was both highly engaging and mathematically sound.
Let’s examine how each LLM contributed to the modern build of SQL Poker across several key technical categories. The following table highlights their performance, showing the strengths and weaknesses that emerged during testing. This comparative data showcases where each artificial intelligence model shines when faced with complex database programming tasks.
| Feature / Metric | Claude Code (Fable 5) | ChatGPT Codex (5.6 Sol) |
|---|---|---|
| Gameplay Flow | Highly interactive; utilizes active waits for seamless turns. | Turn-based; requires more manual execution of statements. |
| Bot Logic & AI | Basic, predictable decision-making patterns. | Advanced, aggressive bidding and tactical raises. |
| Security Strategy | Ignored security; left temp tables completely exposed. | Attempted encryption, but committed password to GitHub. |
| Testing Autonomy | Excellent; ran parallel command-line sessions effortlessly. | Excellent; utilized database tools to catch syntax bugs. |
Historical Context of T-SQL Gaming

To understand the origin of SQL Poker, we must look back at the history of database-driven games. Long before generative AI existed, database developers were already writing complex games in pure SQL. Legendary Microsoft SQL Server expert Brad Schulz paved the way decades ago by writing a single-player poker game using complex T-SQL structures. His work showed that relational engines could handle intricate mathematical calculations and game logic without relying on external compilers.
The legacy of writing games inside SQL Server is driven by a desire to push database engines to their absolute limits. While modern web development relies on JavaScript, Python, or Go, writing games in T-SQL forces developers to master complex set-based logic. It transforms mundane tasks like index optimization and transaction handling into a thrilling creative pursuit. It is this passion for problem-solving that inspires developers to build wild projects inside enterprise software.
Modern iterations like SQL Poker build upon this legacy by adding real-time multiplayer support. Tech enthusiasts can read more about famous digital creations and digital celebrities on platforms like Bright Celebrity, which tracks the intersection of tech innovation and modern media. The evolution from text-based terminal games to modern web-connected databases shows how far the database industry has progressed over the last thirty years.
The enthusiastic reception of SQL Poker shows that the database community loves creative programming challenges. It connects the legacy of old-school T-SQL wizards with the futuristic power of automated AI agents. As technology continues to evolve, these playful experiments provide invaluable learning experiences for the next generation of database engineers. They remind us that programming should not just be about business logic, but also about the joy of building something unique.
Security Vulnerabilities and Database Exploits
Unfortunately, hosting a public game of SQL Poker introduces massive security concerns that developers must address. When you run an online game on a public database instance, you must expect players to search for exploits. This project exposed a massive vulnerability in how AI handles data isolation and security. Because the game state is stored in global temporary tables, any clever player can easily bypass the game’s interface to peek at their opponents’ cards.
A simple SELECT query executed against tempdb reveals the exact hole cards of every player at the table. In the world of high-stakes gambling, this is the equivalent of playing with transparent cards. During code review, GitHub Copilot flagrantly called out ChatGPT Codex for this massive security oversight, noting that the program lacked actual data privacy. It showed that the AI had prioritized functional performance over fundamental security best practices.
Many players will try to hack SQL Poker by executing direct queries against hidden database tables. To resolve this, the Codex model attempted to implement SQL Server certificates to secure the data. However, in a hilarious turn of events, the AI checked the database certificate along with its plaintext password directly into the public GitHub repository. This mistake highlights why human oversight remains completely non-negotiable in the era of AI-driven software development.
Furthermore, nothing stops a malicious user from running an UPDATE statement on the global temporary tables to manually change their hand to a royal flush. While this makes the game highly insecure for real money, it offers an incredible playground for database administrators to practice penetration testing. It serves as a stark reminder of the security challenges that modern cloud databases must overcome daily. Security is always a moving target, and databases are no exception.
By The Numbers: Statistics show that security audits for games like SQL Poker often reveal simple logic flaws. In modern software engineering, approximately 75% of security vulnerabilities in AI-generated code stem from improper input validation or insecure data storage practices. While LLMs are highly proficient at generating syntactically correct code, they frequently fail to apply security best practices unless explicitly prompted to do so. In the case of database programming, separating user privileges and locking down tempdb access remains a task that only experienced database administrators can execute reliably.
Frequently Asked Questions
How do I play SQL Poker on Azure SQL Database?
To join a live game of SQL Poker, you must connect your SQL Server Management Studio to the serverless Azure instance. Once connected, you can run the sp_TexasHoldEm stored procedure, which will automatically place you at an open seat or let you spectate if the table is full.
Can I run this game on my local SQL Server instance?
Yes, the entire source code and database setup scripts are publicly available on GitHub. You can easily deploy the stored procedure on any local SQL Server or Azure SQL Database instance and play against automated robots or local colleagues.
Is SQL Poker safe for actual financial gambling?
No, because SQL Poker uses unencrypted temporary tables, making it highly vulnerable to cheating and database exploits. Anyone with basic SQL knowledge can query the temporary tables to see their opponents’ cards or manually alter their chip stack values.
Which AI model wrote the best database code?
Claude Code was highly praised for creating a superior interactive experience using active waiting, while ChatGPT Codex provided better mathematical logic for betting and bot actions. The final version combines elements from both models to offer the best possible gameplay.
The Future of Database AI
As we look ahead, the creation of SQL Poker highlights the incredible potential of generative artificial intelligence. The success of this experiment shows that the relationship between database administration and artificial intelligence is changing rapidly. We are moving away from an era where developers write every single query by hand. Instead, we are entering a phase where AI models act as co-architects, generating massive, functional database systems from simple English prompts.
While these models still make critical mistakes in security and structural design, their speed and debugging autonomy are undeniable. They allow developers to create, test, and deploy complex applications in a fraction of the time it would normally take. This shift will free up database professionals to focus on higher-level architecture, security auditing, and performance tuning, rather than writing boilerplate procedures.
Ultimately, projects like SQL Poker serve as an inspiring proof of concept for future enterprise applications. Playing a game of cards might seem like a silly way to spend a lunch break, but it represents a massive paradigm shift. It proves that with the right prompting, AI can conquer complex, stateful programming challenges in languages as specialized as T-SQL. As long as developers remain vigilant about security, the possibilities for this technology are truly limitless.
So fire up your query editor, load SQL Poker, and enjoy this wild fusion of database engineering and artificial intelligence. Whether you are a seasoned database administrator or a curious software engineer, this project invites you to explore the wilder side of technology. Grab your database client, connect to the server, and see if you have what it takes to win a pile of Query Bucks. After all, in the world of database development, you should always blame the query plan, never the cards.
More Like This
For more updates, check out our latest entertainment and sports news.