Tag: Query Behaviour
-
RAND() vs NEWID() in SQL Server
Most people searching for “random numbers in SQL Server” want one of two things: SQL Server gives you two common tools for this: RAND() and NEWID(). They solve different problems, and confusion usually starts when they are treated as interchangeable. This post shows how to use both, starting with simple examples, and explains why they…
Written by
-
DBA Scripts: Get Query Performance Deep-Dive
When Top CPU Doesn’t Explain “Why Is This Slow” The query usually runs fine and sometimes takes forever, or the server is slow and Top CPU Queries names nothing that explains it. A CPU ranking tells you what was busy, not why something was slow. These four scripts go after the usual reasons it misses:…
Written by
-
How to Increase Maximum Characters Displayed in SSMS
⚡Tools → Options, search for “results to text”, and raise Maximum number of characters displayed in each column. Then open a new query window. The default is 256, and output past it is cut off without a warning. By default, SQL Server Management Studio limits the number of characters displayed per column when using Results…
Written by
-
Understanding WHERE 1=1 and WHERE 1=2 in SQL Queries
⚡Neither changes the plan or the speed of a query. WHERE 1=1 lets every real condition start with AND, so conditions can be commented out or appended in dynamic SQL. WHERE 1=2 returns no rows without reading the table, which is how SELECT … INTO copies a table’s columns and nothing else. You have opened…
Written by
-
What the USE Command Does in SQL Server
The USE command changes the database context for the current session. Every statement in SQL Server runs in the context of a database. When you run USE, you are telling SQL Server which database subsequent statements should execute against until the context changes again or the session ends. That single behaviour explains a lot of…
Written by
- Tune a Slow Query With Copilot in SSMS
- xp_readerrorlog: Read the SQL Server Error Log with T-SQL
- Cannot Drop Database Because It Is Currently in Use (Error 3702)
- Could Not Drop Login Because the User Is Currently Logged In (Error 15434)
- Set a Maximum Database File Size in SQL Server (MAXSIZE)
- SQL Server Activity Monitor in SSMS (and the Performance Dashboard)
- Backups & Recovery (18)
- DBA Scripts (154)
- High Availability (HA) (13)
- Installation & Configuration (60)
- Maintenance (25)
- Migration & Upgrades (14)
- Monitoring (10)
- Performance Tuning (38)
- Security (Encryption & Permissions) (25)
- Storage & Capacity (18)
- T-SQL Fundamentals (17)
- Troubleshooting (108)
- Wait Types (236)