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 an Always Encrypted Column Rejecting a Simple WHERE Equality Filter Because It Uses Randomized Instead of Deterministic Encryption

- 06.11.26 - ErcanOPAK comment on SQL Server: Fix an Always Encrypted Column Rejecting a Simple WHERE Equality Filter Because It Uses Randomized Instead of Deterministic Encryption

🗄️ SQL Server: Fix an Always Encrypted Column Rejecting a Simple WHERE Equality Filter Because It Uses Randomized Instead of Deterministic Encryption Always Encrypted supports two encryption types per column: deterministic, which always produces the same ciphertext for the same plaintext value and therefore supports equality comparisons directly, and randomized, which produces different ciphertext every […]

Read More
SQL

SQL Server: Fix a Query’s Actual Row Count Coming in Far Higher Than Estimated Because a Multi-Statement Table-Valued Function Always Reports the Same Flat Guess to the Optimizer

- 06.11.26 - ErcanOPAK comment on SQL Server: Fix a Query’s Actual Row Count Coming in Far Higher Than Estimated Because a Multi-Statement Table-Valued Function Always Reports the Same Flat Guess to the Optimizer

🗄️ SQL Server: Fix a Query’s Actual Row Count Coming in Far Higher Than Estimated Because a Multi-Statement Table-Valued Function Always Reports the Same Flat Guess to the Optimizer A multi-statement table-valued function’s body is opaque to the query optimizer at compile time — unlike a view or an inline function, whose logic can be […]

Read More
SQL

SQL Server: Fix a Query Store Forced Plan Silently Stopping Enforcement Because a Schema Change Invalidated the Captured Plan

- 05.11.26 - ErcanOPAK comment on SQL Server: Fix a Query Store Forced Plan Silently Stopping Enforcement Because a Schema Change Invalidated the Captured Plan

🗄️ SQL Server: Fix a Query Store Forced Plan Silently Stopping Enforcement Because a Schema Change Invalidated the Captured Plan Forcing a plan through Query Store pins a query to a specific, previously-captured execution plan by its plan ID. A schema change affecting any object that plan depends on — dropping or rebuilding an index […]

Read More
SQL

SQL Server: Fix a Window Function’s ORDER BY Silently Changing Row Order in the Final Result Because It Only Controls Frame Calculation, Not Output Order

- 05.11.26 - ErcanOPAK comment on SQL Server: Fix a Window Function’s ORDER BY Silently Changing Row Order in the Final Result Because It Only Controls Frame Calculation, Not Output Order

🗄️ SQL Server: Fix a Window Function’s ORDER BY Silently Changing Row Order in the Final Result Because It Only Controls Frame Calculation, Not Output Order The ORDER BY clause inside a window function’s OVER() — SUM(amount) OVER (PARTITION BY account ORDER BY txn_date), say — exists purely to define the order rows are considered […]

Read More
SQL

SQL Server: Fix a Query Plan Silently Ignoring a Foreign Key for Join Elimination Because the Constraint Was Added WITH NOCHECK and Is Marked Untrusted

- 04.11.26 - ErcanOPAK comment on SQL Server: Fix a Query Plan Silently Ignoring a Foreign Key for Join Elimination Because the Constraint Was Added WITH NOCHECK and Is Marked Untrusted

🗄️ Fix a Query Plan Silently Ignoring a Foreign Key for Join Elimination Because the Constraint Was Added WITH NOCHECK and Is Marked Untrusted SQL Server’s optimizer can use a trusted foreign key constraint to simplify certain queries — for example, eliminating a join to a referenced table entirely when the query doesn’t actually select […]

Read More
SQL

SQL Server: Fix a Date Range Filter Silently Missing Rows Because BETWEEN Was Used Against a datetime Column That Still Has a Time Component

- 04.11.26 - ErcanOPAK comment on SQL Server: Fix a Date Range Filter Silently Missing Rows Because BETWEEN Was Used Against a datetime Column That Still Has a Time Component

🗄️ Fix a Date Range Filter Silently Missing Rows Because BETWEEN Was Used Against a datetime Column That Still Has a Time Component BETWEEN ‘2026-01-01’ AND ‘2026-01-31’ against a datetime column is shorthand for a range check between two exact instants, and SQL Server resolves the bare date literal on the end of that range […]

Read More
SQL

SQL Server: Fix a Linked Server Query Pulling an Entire Remote Table Across the Network Because the Provider Can’t Push a Simple Predicate Down to It

- 02.11.26 - ErcanOPAK comment on SQL Server: Fix a Linked Server Query Pulling an Entire Remote Table Across the Network Because the Provider Can’t Push a Simple Predicate Down to It

🗄️ Fix a Linked Server Query Pulling an Entire Remote Table Across the Network Because the Provider Can’t Push a Simple Predicate Down to It A query against a linked server is only as efficient as the provider’s ability to translate a local WHERE clause into something the remote engine can filter with before sending […]

Read More
SQL

SQL Server: Fix a Temporal Table Query Against a Point in Time Silently Missing Rows Because the System-Time Comparison Defaults to an Exclusive Upper Bound

- 02.11.26 - ErcanOPAK comment on SQL Server: Fix a Temporal Table Query Against a Point in Time Silently Missing Rows Because the System-Time Comparison Defaults to an Exclusive Upper Bound

🗄️ Fix a Temporal Table Query Against a Point in Time Silently Missing Rows Because the System-Time Comparison Defaults to an Exclusive Upper Bound System-versioned temporal tables let you query historical state with FOR SYSTEM_TIME AS OF @asOfTime, which SQL Server implements internally as a range filter: a row qualifies only when ValidFrom <= @asOfTime […]

Read More
SQL

SQL Server: Fix a Query Returning Different Row Counts on Reruns Because It Reads a Table Variable Populated Inside the Same Transaction as a Concurrent Writer

- 01.11.26 - ErcanOPAK comment on SQL Server: Fix a Query Returning Different Row Counts on Reruns Because It Reads a Table Variable Populated Inside the Same Transaction as a Concurrent Writer

🗄️ Fix a Query Returning Different Row Counts on Reruns Because It Reads a Table Variable Populated Inside the Same Transaction as a Concurrent Writer A table variable is populated once, explicitly, by whatever INSERT or SELECT INTO statement fills it, and from that point on it behaves like a private, disconnected snapshot – nothing […]

Read More
SQL

SQL Server: Fix Change Data Capture Silently Stopping Because the Transaction Log Was Truncated Before the Capture Job Could Read It

- 01.11.26 - ErcanOPAK comment on SQL Server: Fix Change Data Capture Silently Stopping Because the Transaction Log Was Truncated Before the Capture Job Could Read It

🗄️ Fix Change Data Capture Silently Stopping Because the Transaction Log Was Truncated Before the Capture Job Could Read It Change Data Capture relies on its capture job reading committed changes out of the transaction log asynchronously, after the fact, rather than capturing them synchronously at commit time, which is exactly what keeps CDC’s overhead […]

Read More
SQL

SQL Server: Fix Columnstore Compression Silently Degrading Because Frequent Small Updates Keep Rows Stuck in the Delta Store

- 01.11.26 - ErcanOPAK comment on SQL Server: Fix Columnstore Compression Silently Degrading Because Frequent Small Updates Keep Rows Stuck in the Delta Store

🗄️ Fix Columnstore Compression Silently Degrading Because Frequent Small Updates Keep Rows Stuck in the Delta Store A columnstore index keeps newly inserted or updated rows in a row-oriented delta store until enough of them accumulate, usually around a million rows, for the background tuple mover to compress them into the efficient columnar format the […]

Read More
SQL

SQL Server: Fix a Partitioned Table Query Silently Scanning Every Partition Because the Predicate Compared the Partition Column to a Variable of a Mismatched Data Type

- 01.11.26 - ErcanOPAK comment on SQL Server: Fix a Partitioned Table Query Silently Scanning Every Partition Because the Predicate Compared the Partition Column to a Variable of a Mismatched Data Type

🗄️ Fix a Partitioned Table Query Silently Scanning Every Partition Because the Predicate Compared the Partition Column to a Variable of a Mismatched Data Type Partition elimination lets the query optimizer skip straight to the handful of partitions a query could possibly need, but it can only make that decision when it can map the […]

Read More
SQL

SQL Server: Fix a Service Broker Queue That Silently Stops Processing Messages Because the Activation Procedure Hit an Unhandled Error and Disabled Itself

- 01.11.26 - ErcanOPAK comment on SQL Server: Fix a Service Broker Queue That Silently Stops Processing Messages Because the Activation Procedure Hit an Unhandled Error and Disabled Itself

🗄️ Fix a Service Broker Queue That Silently Stops Processing Messages Because the Activation Procedure Hit an Unhandled Error and Disabled Itself Service Broker’s activation feature starts an instance of a configured stored procedure automatically whenever messages arrive on a queue with nothing currently processing them, which is what makes Service Broker feel like a […]

Read More
SQL

SQL Server: Fix Change Tracking Silently Dropping Rows Because the Retention Window Was Shorter Than the Consumer’s Polling Interval

- 01.11.26 - ErcanOPAK comment on SQL Server: Fix Change Tracking Silently Dropping Rows Because the Retention Window Was Shorter Than the Consumer’s Polling Interval

🗄️ Fix Change Tracking Silently Dropping Rows Because the Retention Window Was Shorter Than the Consumer’s Polling Interval Change Tracking records row-level insert, update, and delete versions for a table and lets a consumer ask for everything that’s changed since the last version it successfully processed, which is a lightweight and efficient way to build […]

Read More
SQL

SQL Server: Fix a Sort Operator That Spills to TempDB and Crawls Because Its Memory Grant Was Estimated Off Statistics From Before a Bulk Load Tripled the Table’s Row Count

- 31.10.26 - ErcanOPAK comment on SQL Server: Fix a Sort Operator That Spills to TempDB and Crawls Because Its Memory Grant Was Estimated Off Statistics From Before a Bulk Load Tripled the Table’s Row Count

🗄️ Fix a Sort Operator That Spills to TempDB and Crawls Because Its Memory Grant Was Estimated Off Statistics From Before a Bulk Load Tripled the Table’s Row Count SQL Server estimates how much memory a query’s sort and hash operators will need before the query ever runs, based entirely on the cardinality estimates its […]

Read More
SQL

SQL Server: Fix a Readable Secondary Replica’s Query Optimizer Using Outdated Statistics Because a Secondary Replica Can’t Auto-Update Its Own Statistics

- 31.10.26 - ErcanOPAK comment on SQL Server: Fix a Readable Secondary Replica’s Query Optimizer Using Outdated Statistics Because a Secondary Replica Can’t Auto-Update Its Own Statistics

🗄️ Fix a Readable Secondary Replica’s Query Optimizer Using Outdated Statistics Because a Secondary Replica Can’t Auto-Update Its Own Statistics Automatic statistics updates in SQL Server work by having a session’s own query trigger a background or synchronous update once enough rows have changed since the last one, which requires that session to be running […]

Read More
SQL

SQL Server: Fix Replication Subscribers Falling Permanently Behind Because the Distribution Agent’s Retry Interval Is Longer Than the Publisher’s Transaction Log Retention

- 31.10.26 - ErcanOPAK comment on SQL Server: Fix Replication Subscribers Falling Permanently Behind Because the Distribution Agent’s Retry Interval Is Longer Than the Publisher’s Transaction Log Retention

🗄️ Fix Replication Subscribers Falling Permanently Behind Because the Distribution Agent’s Retry Interval Is Longer Than the Publisher’s Transaction Log Retention Transactional replication keeps a subscriber caught up by having the distribution agent continuously pull newly logged commands out of the distribution database and apply them at the subscriber, and when a subscriber or the […]

Read More
SQL

SQL Server: Fix a Resumable Index Rebuild That Restarts From Zero Progress Because the Pause Window Ran Past Its Max Duration and Was Abandoned

- 31.10.26 - ErcanOPAK comment on SQL Server: Fix a Resumable Index Rebuild That Restarts From Zero Progress Because the Pause Window Ran Past Its Max Duration and Was Abandoned

🗄️ Fix a Resumable Index Rebuild That Restarts From Zero Progress Because the Pause Window Ran Past Its Max Duration and Was Abandoned Resumable index rebuilds are built specifically so a large rebuild can be paused during a busy period and picked back up later without starting over, tracking its progress through SQL Server’s own […]

Read More
SQL

SQL Server: Fix a Foreign Key Constraint Allowing an Update That Should Have Failed Because It Was Created With NOCHECK and Never Revalidated

- 31.10.26 - ErcanOPAK comment on SQL Server: Fix a Foreign Key Constraint Allowing an Update That Should Have Failed Because It Was Created With NOCHECK and Never Revalidated

🗄️ Fix a Foreign Key Constraint Allowing an Update That Should Have Failed Because It Was Created With NOCHECK and Never Revalidated Adding a foreign key constraint to a table that already has rows in it with WITH NOCHECK is a common move when the existing data is known to already have some violations that […]

Read More
SQL

SQL Server: Fix a Computed Column Returning Stale Values Because It Wasn’t Marked PERSISTED and the Underlying Function Isn’t Deterministic

- 31.10.26 - ErcanOPAK comment on SQL Server: Fix a Computed Column Returning Stale Values Because It Wasn’t Marked PERSISTED and the Underlying Function Isn’t Deterministic

🗄️ Fix a Computed Column Returning Stale Values Because It Wasn’t Marked PERSISTED and the Underlying Function Isn’t Deterministic A computed column defined without the PERSISTED keyword isn’t actually stored on disk at all; SQL Server recalculates its value on the fly every time a query reads it, using the column’s defining expression against that […]

Read More
SQL

SQL Server: Fix a Columnstore Index Query Running Slower Than a Rowstore Scan Because Too Many Rows Still Sit Uncompressed in the Deltastore

- 31.10.26 - ErcanOPAK comment on SQL Server: Fix a Columnstore Index Query Running Slower Than a Rowstore Scan Because Too Many Rows Still Sit Uncompressed in the Deltastore

🗄️ Fix a Columnstore Index Query Running Slower Than a Rowstore Scan Because Too Many Rows Still Sit Uncompressed in the Deltastore A columnstore index gets its performance advantage from storing data in large, compressed, column-oriented rowgroups that SQL Server can scan in an efficient batch mode. New or recently modified rows do not go […]

Read More
SQL

SQL Server: Fix a Scalar Function Making a Set-Based Query Run Row by Row Because Scalar UDF Inlining Needs Compatibility Level 150 or Higher

- 31.10.26 - ErcanOPAK comment on SQL Server: Fix a Scalar Function Making a Set-Based Query Run Row by Row Because Scalar UDF Inlining Needs Compatibility Level 150 or Higher

🗄️ Fix a Scalar Function Making a Set-Based Query Run Row by Row Because Scalar UDF Inlining Needs Compatibility Level 150 or Higher Calling a scalar user-defined function inside an otherwise set-based query has historically forced SQL Server to execute that function once per row, invisibly turning a query that looks declarative into something that […]

Read More
SQL

SQL Server: Fix a Temporal Table’s History Table Growing Forever Because Nobody Ever Configured a Retention Policy

- 30.10.26 - ErcanOPAK comment on SQL Server: Fix a Temporal Table’s History Table Growing Forever Because Nobody Ever Configured a Retention Policy

🗄️ Fix a Temporal Table’s History Table Growing Forever Because Nobody Ever Configured a Retention Policy System-versioned temporal tables automatically copy the previous version of every changed row into a linked history table whenever an UPDATE or DELETE happens, which is exactly what makes point-in-time queries with FOR SYSTEM_TIME work. What SQL Server does not […]

Read More
SQL

SQL Server: Fix an UPDATE That Reports Success but Changes Zero Rows Because a Trigger Rolled Back the Transaction Silently

- 30.10.26 - ErcanOPAK comment on SQL Server: Fix an UPDATE That Reports Success but Changes Zero Rows Because a Trigger Rolled Back the Transaction Silently

🗄️ Fix an UPDATE That Reports Success but Changes Zero Rows Because a Trigger Rolled Back the Transaction Silently An AFTER UPDATE trigger that calls ROLLBACK TRANSACTION inside its own body doesn’t just undo the trigger’s own work — it rolls back the entire outer transaction, including the UPDATE statement that fired it in the […]

Read More
SQL

SQL Server: Fix a CTE That Gets Re-Evaluated Once Per Reference Instead of Once, Doubling the Work for No Reason

- 30.10.26 - ErcanOPAK comment on SQL Server: Fix a CTE That Gets Re-Evaluated Once Per Reference Instead of Once, Doubling the Work for No Reason

🗄️ Fix a CTE That Gets Re-Evaluated Once Per Reference Instead of Once, Doubling the Work for No Reason A non-recursive common table expression isn’t materialized the way a temp table is — SQL Server’s optimizer is free to treat the CTE’s definition like an inline macro and expand it separately everywhere it’s referenced in […]

Read More
SQL

SQL Server: Fix a Trigger Silently Not Firing on a Bulk Insert Because the Bulk Copy Operation Was Run With FIRE_TRIGGERS Left Off

- 30.10.26 - ErcanOPAK comment on SQL Server: Fix a Trigger Silently Not Firing on a Bulk Insert Because the Bulk Copy Operation Was Run With FIRE_TRIGGERS Left Off

🗄️ Fix a Trigger Silently Not Firing on a Bulk Insert Because the Bulk Copy Operation Was Run With FIRE_TRIGGERS Left Off `BULK INSERT`, `bcp`, and `SqlBulkCopy` from application code are all built to load large volumes of data with as little per-row overhead as possible — and part of that design is that none […]

Read More
SQL

SQL Server: Fix a Query Hint Being Silently Ignored Because an Existing Plan Guide Was Already Forcing a Different Plan for That Exact Query Text

- 30.10.26 - ErcanOPAK comment on SQL Server: Fix a Query Hint Being Silently Ignored Because an Existing Plan Guide Was Already Forcing a Different Plan for That Exact Query Text

🗄️ Fix a Query Hint Being Silently Ignored Because an Existing Plan Guide Was Already Forcing a Different Plan for That Exact Query Text A plan guide attaches a forced plan or a fixed set of hints to a query identified by matching its exact text (or a parameterized template of it), completely independent of […]

Read More
SQL

SQL Server: Fix a Partitioned Table’s Partition Switch Silently Failing Because the Staging Table’s Constraints Don’t Exactly Match the Partition’s Boundary Values

- 30.10.26 - ErcanOPAK comment on SQL Server: Fix a Partitioned Table’s Partition Switch Silently Failing Because the Staging Table’s Constraints Don’t Exactly Match the Partition’s Boundary Values

🗄️ Fix a Partitioned Table’s Partition Switch Silently Failing Because the Staging Table’s Constraints Don’t Exactly Match the Partition’s Boundary Values ALTER TABLE … SWITCH requires the staging table to carry a CHECK constraint that SQL Server can algebraically verify covers exactly the same range as the target partition’s boundary – and that verification is […]

Read More
SQL

SQL Server: Fix a Stored Procedure That’s Fast the First Time and Slow Every Time After Because Its Cached Plan Was Compiled Against an Empty Table

- 29.10.26 - ErcanOPAK comment on SQL Server: Fix a Stored Procedure That’s Fast the First Time and Slow Every Time After Because Its Cached Plan Was Compiled Against an Empty Table

🗄️ Fix a Stored Procedure That’s Fast the First Time and Slow Every Time After Because Its Cached Plan Was Compiled Against an Empty Table SQL Server compiles and caches an execution plan for a stored procedure the first time it’s called, using the actual parameter values and the table statistics available at that exact […]

Read More
SQL

SQL Server: Fix an ORDER BY That Works Fine in SSMS but Returns Unsorted Rows From the App Because a Paging Helper Drops It Before Adding OFFSET FETCH

- 29.10.26 - ErcanOPAK comment on SQL Server: Fix an ORDER BY That Works Fine in SSMS but Returns Unsorted Rows From the App Because a Paging Helper Drops It Before Adding OFFSET FETCH

🗄️ Fix an ORDER BY That Works Fine in SSMS but Returns Unsorted Rows From the App Because a Paging Helper Drops It Before Adding OFFSET FETCH OFFSET/FETCH requires a syntactically present ORDER BY clause, so a generic paging helper that builds queries dynamically often falls back to ORDER BY (SELECT NULL) whenever the calling […]

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

Posts pagination

« Previous 1 2 3 4 … 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