Thursday, February 9, 2023

SQL Delete Records within a specific range

SQL Delete Query with BETWEEN condition:

Here i want to delete record from table with in specific range.

BETWEEN condition with WHERE clause can be used to only remove rows with in specific range.

You can use the between function as below:


DELETE FROM [dbo].[TableName] WHERE [TableName].[IdField] BETWEEN 1 AND 25



You can also use below command same as above:


DELETE FROM [dbo].[TableName] 
WHERE [TableName].[IdField] > 10 AND [TableName].[IdField] < 25


You can also use below command same as above:


DELETE FROM [dbo].[TableName] 
WHERE [TableName].[IdField] => 10 AND [TableName].[IdField] <= 25


Please Like & Share...


No comments:

Post a Comment