3 Ways to Return the Number of Rows in Each Partition in SQL Server (T-SQL)

If you’ve previously created a partitioned table in SQL Server, and you now want to know how many rows are being stored in each partition, here are three queries you can use.

In particular, you can:

  • Query the sys.dm_db_partition_stats view
  • Query the sys.partitions view
  • Use the $PARTITION function in a query

Below are examples of all three.

Read more

SQL Not Equal To (<>) Operator for Beginners

In SQL, the not equal to operator (<>) compares the non-equality of two expressions. That is, it tests whether one expression is not equal to another expression.

If either or both operands are NULL, NULL is returned.

SQL also has another not equal to operator (!=), which does the same thing. Which one you use may depend on your DBMS, which one you’re the most comfortable using, and perhaps also whether your organisation has any coding conventions that dictate which one should be used.

Read more

SQL Not Equal To (!=) Operator for Beginners

In SQL, the not equal to operator (!=) compares the non-equality of two expressions. That is, it tests whether one expression is not equal to another expression.

If either or both operands are NULL, NULL is returned.

SQL also has another not equal to operator (<>), which does the same thing. Which one you use may depend on your DBMS, which one you’re the most comfortable using, and perhaps also whether your organisation has any coding conventions that dictate which one should be used.

Read more