Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: SQL

SQL

SQL Server: Fix a Columnstore Archive Compression Job Stalling

- 21.11.26 - ErcanOPAK comment on SQL Server: Fix a Columnstore Archive Compression Job Stalling

🗄️ SQL Server: Fix a Columnstore Archive Compression Job Stalling ALTER INDEX … REORGANIZE WITH (DATA_COMPRESSION = COLUMNSTORE_ARCHIVE) compresses closed row groups further for cold data, but it can only fully archive-compress a row group once it’s already in a COMPRESSED state. If background tuple-mover activity keeps merging row groups concurrently — common on a […]

Read More
SQL

SQL Server: Fix a Graph Table Query Returning Duplicate Edges

- 21.11.26 - ErcanOPAK comment on SQL Server: Fix a Graph Table Query Returning Duplicate Edges

🗄️ SQL Server: Fix a Graph Table Query Returning Duplicate Edges SQL Server’s graph database features let you traverse relationships with a MATCH clause, but a pattern that checks for a relationship in both directions using two separate MATCH clauses joined with OR can match the same underlying edge row twice — once satisfying each […]

Read More
SQL

SQL Server: Fix a Lock Escalation Blocking Unrelated Reads

- 20.11.26 - ErcanOPAK comment on SQL Server: Fix a Lock Escalation Blocking Unrelated Reads

🗄️ Fix a Lock Escalation Blocking Completely Unrelated Reads SQL Server automatically escalates many fine-grained row or page locks held by a single statement into one table-level lock once a configurable threshold – roughly 5,000 locks by default – is crossed, to keep lock management overhead under control. A large UPDATE or DELETE that’s individually […]

Read More
SQL

SQL Server: Fix JSON_VALUE Returning Null for a Valid Path

- 20.11.26 - ErcanOPAK comment on SQL Server: Fix JSON_VALUE Returning Null for a Valid Path

🗄️ Fix JSON_VALUE Returning Null for a Path That Actually Exists JSON_VALUE only ever returns a scalar, and it returns NULL with no error both when a path genuinely doesn’t exist in the stored JSON and when the path exists but resolves to an object or array instead of a scalar – and separately, when […]

Read More
SQL

SQL Server: Fix a Columnstore Index Fragmenting After Bulk Deletes

- 19.11.26 - ErcanOPAK comment on SQL Server: Fix a Columnstore Index Fragmenting After Bulk Deletes

🗄️ Fix a Columnstore Index Fragmenting After Bulk Deletes A columnstore index stores data in large, immutable compressed row groups; a `DELETE` against rows in one doesn’t physically remove them from their row group — it marks them as logically deleted in an internal bitmap while the physical data stays resident on disk and in […]

Read More
SQL

SQL Server: Fix a Trigger Firing Twice on One Merge Statement

- 19.11.26 - ErcanOPAK comment on SQL Server: Fix a Trigger Firing Twice on One Merge Statement

🗄️ Fix a Trigger Firing Twice on One Merge Statement An `AFTER INSERT, UPDATE` trigger on a table targeted by a `MERGE` statement fires once per statement by default, not once per row — but when a `MERGE`’s `WHEN MATCHED` clauses are written with multiple conditions that could each independently match the same source row […]

Read More
SQL

SQL Server: Fix a View Returning Stale Data After a Schema Change

- 18.11.26 - ErcanOPAK comment on SQL Server: Fix a View Returning Stale Data After a Schema Change

🗄️ SQL Server: Fix a View Returning Stale Data After a Schema Change A view defined with SELECT * doesn’t re-derive its column list on every query — SQL Server captures that list once, at the time the view is created or last refreshed, and keeps using it. Add a new column to the underlying […]

Read More
SQL

SQL Server: Fix a Temp Table Causing a Plan Recompile Every Call

- 18.11.26 - ErcanOPAK comment on SQL Server: Fix a Temp Table Causing a Plan Recompile Every Call

🗄️ SQL Server: Fix a Temp Table Causing a Plan Recompile Every Call A stored procedure’s cached execution plan is partly built around the statistics of any #temp table it uses, and SQL Server automatically triggers a recompile whenever those statistics change enough between calls to make the cached plan look unreliable. A temp table […]

Read More
SQL

SQL Server: Fix a Merge Statement Double-Counting Matched Rows

- 17.11.26 - ErcanOPAK comment on SQL Server: Fix a Merge Statement Double-Counting Matched Rows

🗄️ SQL Server: Fix a Merge Statement Double-Counting Matched Rows The actual row modifications a MERGE statement performs are correct even under a parallel execution plan, but Microsoft’s own documentation calls out a specific, narrower gotcha: when a parallel plan is chosen for a MERGE that also uses the OUTPUT clause, that clause can return […]

Read More
SQL

SQL Server: Fix an Identity Column Gap After a Failed Bulk Insert

- 17.11.26 - ErcanOPAK comment on SQL Server: Fix an Identity Column Gap After a Failed Bulk Insert

🗄️ SQL Server: Fix an Identity Column Gap After a Failed Bulk Insert An IDENTITY column’s next value is allocated the moment a row is attempted, not committed, so a bulk insert that fails partway through — or a whole transaction that gets rolled back after identity values were already handed out — leaves a […]

Read More
SQL

SQL Server: Fix a Computed Column Index Skipped by Implicit Cast

- 16.11.26 - ErcanOPAK comment on SQL Server: Fix a Computed Column Index Skipped by Implicit Cast

🗄️ SQL Server: Fix a Computed Column Index Skipped by Implicit Cast A computed column index can only be used when a predicate’s expression matches the computed column’s own definition closely enough for the optimizer to recognize it – including matching data types exactly. Comparing the computed column against a parameter of a different type […]

Read More
SQL

SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs

- 16.11.26 - ErcanOPAK comment on SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs

🗄️ SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs ROW_NUMBER() requires an ORDER BY, but when that ordering expression has ties – multiple rows sharing the exact same value on every column actually listed – SQL Server is free to break the tie using whatever order the rows happen to arrive from the underlying […]

Read More
SQL

SQL Server: Fix TRY_CONVERT Hiding Bad Dates Instead of Erroring

- 15.11.26 - ErcanOPAK comment on SQL Server: Fix TRY_CONVERT Hiding Bad Dates Instead of Erroring

🗄️ SQL Server: Fix TRY_CONVERT Hiding Bad Dates Instead of Erroring TRY_CONVERT is designed to return NULL instead of throwing when a conversion fails — useful for intentionally tolerant parsing. Used on an untrusted or dirty data source, though, a genuinely malformed date string and a legitimately missing source value become completely indistinguishable in the […]

Read More
SQL

SQL Server: Fix Two Equal-Looking DATETIME Values Failing to Match

- 15.11.26 - ErcanOPAK comment on SQL Server: Fix Two Equal-Looking DATETIME Values Failing to Match

🗄️ SQL Server: Fix Two Equal-Looking DATETIME Values Failing to Match Legacy DATETIME stores time internally in increments of roughly 3.33 milliseconds and rounds any value to the nearest one of those increments. A value computed once and stored, then later recomputed independently elsewhere — from .NET DateTime logic with far finer tick precision — […]

Read More
SQL

SQL Server: Fix a Running Total Double-Counting Tied Rows Because the Default Window Frame Is RANGE, Not ROWS

- 14.11.26 - ErcanOPAK comment on SQL Server: Fix a Running Total Double-Counting Tied Rows Because the Default Window Frame Is RANGE, Not ROWS

🗄️ Fix a Running Total Double-Counting Tied Rows Because the Default Window Frame Is RANGE, Not ROWS A window function with an ORDER BY but no explicit frame clause defaults to a RANGE frame running from the start of the partition to the current row, and RANGE treats every row that shares the same ORDER […]

Read More
SQL

SQL Server: Fix Query Store Forcing a Stale Plan Forever After an Index Rebuild Makes a Better One Available

- 14.11.26 - ErcanOPAK comment on SQL Server: Fix Query Store Forcing a Stale Plan Forever After an Index Rebuild Makes a Better One Available

🗄️ Fix Query Store Forcing a Stale Plan Forever After an Index Rebuild Makes a Better One Available Query Store’s plan forcing feature is meant to lock in a known-good execution plan to protect against regressions from parameter sniffing or optimizer changes, but that lock is absolute; it doesn’t re-evaluate whether the forced plan is […]

Read More
SQL

SQL Server: Fix an ORDER BY on an Indexed Column Still Forcing a Sort Because a Join Changed the Row Order First

- 13.11.26 - ErcanOPAK comment on SQL Server: Fix an ORDER BY on an Indexed Column Still Forcing a Sort Because a Join Changed the Row Order First

🗄️ SQL Server: Fix an ORDER BY on an Indexed Column Still Forcing a Sort Because a Join Changed the Row Order First An index on the exact column you’re ordering by only avoids a sort operation in the execution plan if the rows are still being read in that index’s order by the time […]

Read More
SQL

SQL Server: Fix a Filtered Index Never Getting Used Because the Query’s Predicate Compares Against a Parameter Instead of a Literal Value

- 13.11.26 - ErcanOPAK comment on SQL Server: Fix a Filtered Index Never Getting Used Because the Query’s Predicate Compares Against a Parameter Instead of a Literal Value

🗄️ SQL Server: Fix a Filtered Index Never Getting Used Because the Query’s Predicate Compares Against a Parameter Instead of a Literal Value A filtered index only covers the subset of rows that satisfy its own filter predicate (WHERE IsActive = 1, say), and for SQL Server’s optimizer to safely use it for a query, […]

Read More
SQL

SQL Server: Fix a MERGE Statement Deadlocking Against Itself Under Concurrent Runs Because It Takes Update Locks in a Different Order Than a Plain UPDATE Would

- 12.11.26 - ErcanOPAK comment on SQL Server: Fix a MERGE Statement Deadlocking Against Itself Under Concurrent Runs Because It Takes Update Locks in a Different Order Than a Plain UPDATE Would

🗄️ SQL Server: Fix a MERGE Statement Deadlocking Against Itself Under Concurrent Runs Because It Takes Update Locks in a Different Order Than a Plain UPDATE Would `MERGE` is commonly reached for specifically to implement an atomic upsert — insert if the row doesn’t exist, update if it does — and that convenience hides a […]

Read More
SQL

SQL Server: Fix an INSERT INTO … SELECT Deadlocking With a Concurrent Reader Because the Target Table Has No Clustered Index to Order the Lock Acquisition

- 12.11.26 - ErcanOPAK comment on SQL Server: Fix an INSERT INTO … SELECT Deadlocking With a Concurrent Reader Because the Target Table Has No Clustered Index to Order the Lock Acquisition

🗄️ SQL Server: Fix an INSERT INTO … SELECT Deadlocking With a Concurrent Reader Because the Target Table Has No Clustered Index to Order the Lock Acquisition A heap table — one with no clustered index — stores rows in whatever physical order they happened to be inserted, with no guaranteed ordering for SQL Server […]

Read More
SQL

SQL Server: Fix a Column Default of GETDATE() Returning the Identical Timestamp for Every Row of a Bulk Insert Because the Function Evaluates Once Per Statement, Not Once Per Row

- 11.11.26 - ErcanOPAK comment on SQL Server: Fix a Column Default of GETDATE() Returning the Identical Timestamp for Every Row of a Bulk Insert Because the Function Evaluates Once Per Statement, Not Once Per Row

🗄️ SQL Server: Fix a Column Default of GETDATE() Returning the Identical Timestamp for Every Row of a Bulk Insert Because the Function Evaluates Once Per Statement, Not Once Per Row GETDATE() is evaluated by SQL Server’s query processor once per statement execution, not once per row the statement happens to produce — this is […]

Read More
SQL

SQL Server: Fix TRY_CONVERT Returning NULL Instead of Throwing on a Clearly Invalid Value Because a Silent Conversion Failure Looks Identical Downstream to a Genuinely NULL Source Column

- 11.11.26 - ErcanOPAK comment on SQL Server: Fix TRY_CONVERT Returning NULL Instead of Throwing on a Clearly Invalid Value Because a Silent Conversion Failure Looks Identical Downstream to a Genuinely NULL Source Column

🗄️ SQL Server: Fix TRY_CONVERT Returning NULL Instead of Throwing on a Clearly Invalid Value Because a Silent Conversion Failure Looks Identical Downstream to a Genuinely NULL Source Column TRY_CONVERT is deliberately designed to return NULL instead of raising a conversion error whenever the conversion would fail, which is genuinely useful when you expect some […]

Read More
SQL

SQL Server: Fix a Deadlock Graph Showing Two Identical Queries Blocking Each Other Because a Missing Index Forces a Full Table Scan Lock Instead of a Row-Level Lock

- 10.11.26 - ErcanOPAK comment on SQL Server: Fix a Deadlock Graph Showing Two Identical Queries Blocking Each Other Because a Missing Index Forces a Full Table Scan Lock Instead of a Row-Level Lock

🗄️ Fix a Deadlock Graph Showing Two Identical Queries Blocking Each Other Because a Missing Index Forces a Full Table Scan Lock Instead of a Row-Level Lock A deadlock between two sessions running what looks like the exact same UPDATE statement, each targeting a different single row by primary key, shouldn’t normally deadlock at all […]

Read More
SQL

SQL Server: Fix a Query’s Estimated and Actual Row Counts Wildly Disagreeing Because New Rows With Ascending Key Values Keep Falling Outside the Statistics Histogram’s Known Range

- 10.11.26 - ErcanOPAK comment on SQL Server: Fix a Query’s Estimated and Actual Row Counts Wildly Disagreeing Because New Rows With Ascending Key Values Keep Falling Outside the Statistics Histogram’s Known Range

🗄️ Fix a Query’s Estimated and Actual Row Counts Wildly Disagreeing Because New Rows With Ascending Key Values Keep Falling Outside the Statistics Histogram’s Known Range SQL Server’s statistics histogram for a column records the distribution of values it saw as of the last time statistics were updated, with a defined upper bound — the […]

Read More
SQL

SQL Server: Fix NOLOCK Returning the Same Row Twice in One Query Because an Allocation-Order Scan Can Revisit a Page That a Concurrent Update Just Relocated

- 09.11.26 - ErcanOPAK comment on SQL Server: Fix NOLOCK Returning the Same Row Twice in One Query Because an Allocation-Order Scan Can Revisit a Page That a Concurrent Update Just Relocated

🗄️ Fix NOLOCK Returning the Same Row Twice in One Query Because an Allocation-Order Scan Can Revisit a Page That a Concurrent Update Just Relocated The NOLOCK hint, or READ UNCOMMITTED isolation, tells SQL Server to read data pages without taking or honoring locks, which is usually understood as “might see uncommitted data” or “might […]

Read More
SQL

SQL Server: Fix the Optimizer Choosing a Table Scan Over an Existing Index Because the Column’s Low Cardinality Makes the Index Look Unhelpful

- 09.11.26 - ErcanOPAK comment on SQL Server: Fix the Optimizer Choosing a Table Scan Over an Existing Index Because the Column’s Low Cardinality Makes the Index Look Unhelpful

🗄️ Fix the Optimizer Choosing a Table Scan Over an Existing Index Because the Column’s Low Cardinality Makes the Index Look Unhelpful SQL Server’s query optimizer estimates, for every candidate index, how many rows a seek through it would actually touch for the predicate in question, using that column’s statistics — not just whether an […]

Read More
SQL

SQL Server: Fix a CTE Referenced Twice in the Same Query Computing Its Result Set Twice Because SQL Server Doesn’t Materialize a Non-Recursive CTE by Default

- 08.11.26 - ErcanOPAK comment on SQL Server: Fix a CTE Referenced Twice in the Same Query Computing Its Result Set Twice Because SQL Server Doesn’t Materialize a Non-Recursive CTE by Default

🗄️ SQL Server: Fix a CTE Referenced Twice in the Same Query Computing Its Result Set Twice Because SQL Server Doesn’t Materialize a Non-Recursive CTE by Default A Common Table Expression is effectively a named, inline view for the duration of a single query — SQL Server doesn’t automatically compute it once and cache the […]

Read More
SQL

SQL Server: Fix a Parameterized Query Using a Bad Cached Execution Plan for Every Caller Because the First Call’s Unusual Parameter Value Skewed the Optimizer’s Row Estimate

- 08.11.26 - ErcanOPAK comment on SQL Server: Fix a Parameterized Query Using a Bad Cached Execution Plan for Every Caller Because the First Call’s Unusual Parameter Value Skewed the Optimizer’s Row Estimate

🗄️ SQL Server: Fix a Parameterized Query Using a Bad Cached Execution Plan for Every Caller Because the First Call’s Unusual Parameter Value Skewed the Optimizer’s Row Estimate SQL Server caches one execution plan per distinct query text, and for a parameterized query that plan gets built using the ACTUAL parameter value supplied on the […]

Read More
SQL

SQL Server: Fix a FORCESEEK Query Hint Causing New Deadlocks Because It Forces a Narrow Row Lock Instead of the Page Lock the Optimizer Would Have Chosen on Its Own

- 07.11.26 - ErcanOPAK comment on SQL Server: Fix a FORCESEEK Query Hint Causing New Deadlocks Because It Forces a Narrow Row Lock Instead of the Page Lock the Optimizer Would Have Chosen on Its Own

🗄️ SQL Server: Fix a FORCESEEK Query Hint Causing New Deadlocks Because It Forces a Narrow Row Lock Instead of the Page Lock the Optimizer Would Have Chosen on Its Own The FORCESEEK query hint tells the optimizer to use an index seek instead of a scan regardless of its own cost-based judgment, which is […]

Read More
SQL

SQL Server: Fix a Stored Procedure’s Table-Valued Parameter Silently Ignoring a Newly Added Column Because the Calling Code’s DataTable Schema Was Never Updated to Match

- 07.11.26 - ErcanOPAK comment on SQL Server: Fix a Stored Procedure’s Table-Valued Parameter Silently Ignoring a Newly Added Column Because the Calling Code’s DataTable Schema Was Never Updated to Match

🗄️ SQL Server: Fix a Stored Procedure’s Table-Valued Parameter Silently Ignoring a Newly Added Column Because the Calling Code’s DataTable Schema Was Never Updated to Match A table-valued parameter binds a client-side DataTable to a user-defined table type by column position and type, not by matching column names against whatever the stored procedure’s logic expects […]

Read More
Page 1 of 17
1 2 3 4 5 6 … 17 Next »

Posts pagination

1 2 3 … 17 Next »
November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (577)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com