Here are four methods you can use to find duplicate rows in SQL Server.
By “duplicate rows” I mean two or more rows that share exactly the same values across all columns.
Continue readingHere are four methods you can use to find duplicate rows in SQL Server.
By “duplicate rows” I mean two or more rows that share exactly the same values across all columns.
Continue readingHere are three examples of returning rows that contain alphanumeric characters in SQL Server.
Alphanumeric characters are alphabetic and numeric characters.
Continue readingThe following example uses T-SQL to delete duplicate rows in SQL Server.
To be more specific, it deletes duplicate rows but keeps one. So if you have two identical rows, it deletes one of them and keeps the other. In other words, it de-dupes the table.
Continue readingBelow are three ways we can use T-SQL to return a list of databases in SQL Server.
Continue readingThere are several ways to show a list of databases in SQL Server. Probably the easiest way is to use the sp_databases
stored procedure.
The sp_databases
stored procedure is a kind of SQL Server equivalent to the SHOW DATABASES
command that can be used with DBMSs such as MySQL and MariaDB. OK, maybe they aren’t strictly equivalents, but based on their ease of use, they could be viewed as such from a user’s perspective.
In SQL Server, the TODATETIMEOFFSET()
function was specifically designed to return a datetimeoffset value from a datetime2 value.
Given the fact that the datetime2 data type doesn’t actually support time zone offsets, and datetimeoffset must contain the offset, the TODATETIMEOFFSET()
function allows you to specify a time zone offset to use.
This article provides some examples to demonstrate.
Continue readingIn SQL Server, you can use the LOGINPROPERTY()
to return information about login policy settings.
This includes being able to return data for bad password attempts, as well as the time of the last failed login attempt due to a bad password.
Continue readingYou can use the SUSER_ID()
function to return the login identification number of the current user.
You can also use it to return the login ID of another user.
This is similar to returning the current login name, except here we’re returning the ID instead.
Continue readingOccasionally you might find yourself in the situation where you need to get the name of the current workstation that’s connected to SQL Server.
For example, maybe you have a stored procedure that inserts data, and you want to record the name of the workstation that inserted the data.
In such cases, you can use the HOST_NAME()
function.
This is not to be confused with getting the server name.
Continue readingYou can use the SWITCHOFFSET()
function in SQL Server to change the time zone offset on a datetimeoffset value.
The function accepts two arguments; a datetimeoffset(n) value (or an expression that can be resolved to a datetimeoffset(n) value), and the new time zone.
Continue reading