Use the TRUNCATE TABLE command instead of DELETE ALL FROM [table] if you need to remove all records: The TRUNCATE command will, in most cases,take less time than DELETE especially for large tables. WHY? TRUNCATE doesn’t log each deleted row in the transaction log while DELETE does.
If you work with SQL Server, you may have encountered situations where you need to check if an object exists in your database. This could be a table, view, stored procedure, or any other type of object. In this article, we’ll explore two methods for checking if an object exists in SQL Server. Method 1:
Using wildcards in the LIKE clause of a MySQL query can save a lot of effort when you write a query that looks for a pattern in a character string. Just as a refresher, the standard wildcard characters are: % substitute for any characters at the BEGINING or END of the string. _ substitute for any single character.
Often you’ll run into cases where a SQL Server table will contain duplicate rows and you’re tasked with removing them. Here’s one way to do it with a PARTITION BY. I blame the front-end developers when this happens, even if I’m the sole developer of the app. 😊 In the following SQL scripts, we will
How do I add a zero in front of a string in SQL? 2 Easy Ways and 1 Weird Way There are several ways to add a zero to a string in SQL, with minor syntax differences depending on what database you’re using. Let’s start with the easiest method, string concatenation with sample code for