SQL Script

SQL Script to Verify the Database backup file

Here is the SQL Script to be able to Verify the Database Backup file before you want to Restore it. This will let you know if your Backup is fine and usable or Corrupt and not usable.

RESTORE VERIFYONLY
FROM DISK='C:\YourDatabase.bak'

GO

IF @@ERROR = 0
BEGIN
PRINT 'Your Backup is in a Usable State'
END
ELSE
BEGIN
PRINT 'Sorry, Your Backup is corrupt and is not in a Usable State'
END
GO

How to Find Duplicate Rows in a Table in SQL Server?

Duplicate Rows in a table can be very irritating and cause for many headaches. So how can you identify duplicate rows in a table?  SQL Server provides no visual tool or a built in function to show you the duplicate rows in a table, so you need to write your own query to get the duplicate rows.

How to get the Row Count of each table in a Database in SQL Server?

If you are working with SQL Server and looking for a way to get the row count of all tables in your database, you can do that using this SQL Query.

This Query will display a list of all Tables in your database and a count of the number of Rows the table has.

DateTime Craziness in SQL Server when looking for records within a date range

Working with the DataTime datatype in SQL Server can be very frustrating at times Especially, when you use them in your where clause. For example If you want to list all records within a certain date range, you might end up retrieving incorrect rows.

How to check your SQL Server Version?

If you come across some strange differences in your SQL Server or SQL Management Studio in comparisons to what others are using, you are sure to be tempted to want to check you version number to make sure if you have the latest version with all the latest Service Packs Installed.

Here this table should help you to understand which version you have.
The following table lists the Sqlservr.exe version number.

Pages