In SQL Server, the REPLACE()
function enables us to replace a string with another string. But what if you want to replace a list of characters with another list of characters?
The TRANSLATE()
function might help.
In SQL Server, the REPLACE()
function enables us to replace a string with another string. But what if you want to replace a list of characters with another list of characters?
The TRANSLATE()
function might help.
In SQL Server, the OPENQUERY
rowset function enables you to execute a pass-through query on a linked server.
OPENQUERY
is commonly referenced in the FROM
clause of a query as if it were a table, but it can also be referenced as the target table of an INSERT
, UPDATE
, or DELETE
statement.
This article presents an example of using OPENQUERY
to do an DELETE
pass-through query.
If you use SQL Server Management Studio (SSMS) or some other GUI to manage your databases, you might be used to backing up and restoring databases using “point and click”.
Usually this involves right-clicking on the database and selecting Restore or similar, then following the prompts (for example, when restoring a database in Azure Data Studio).
But if you ever need to do it with T-SQL, you can use the RESTORE DATABASE
statement.
There are several ways to get the language currently being used in SQL Server.
The language of the current session will often be the default language for the login, but this is not necessarily always the case. A user can change the current language during the session.
Also, some of SQL Server’s built-in functions accept an argument that allows you to specify a language for that specific query.
This article shows you how to return the language currently being used.
Continue readingTSQL provides the DATEPART()
function, which enables us to return the day of the year for a given date in SQL Server.
By “day of the year”, I mean the day number of the given year.
Continue readingIn SQL Server, you can use OPENQUERY
to execute a pass-through query on a linked server.
OPENQUERY
is commonly referenced in the FROM
clause of a query as if it were a table, but it can also be referenced as the target table of an INSERT
, UPDATE
, or DELETE
statement.
This article presents an example of using OPENQUERY
to do an INSERT
pass-through query.
In SQL Server you can use the REPLACE()
function to replace all occurrences of a string with another string.
The function accepts three arguments; the string that contains the string to be replaced, the string to be replaced, and the string to replace it.
Continue readingIn SQL Server, you can use the MONTH()
function to convert a month name to its corresponding number.
SQL Server provides the STUFF()
function that enables you to insert a string inside another string.
The function also allows you to specify the number of characters (if any) to delete from the original string in order to fit the new string.
Continue readingThere are several ways to return the year from a date in SQL Server. Here are three (or is it four?).
Continue reading