Return the Current Workstation Name that’s Connected to SQL Server (T-SQL)

Occasionally 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 reading

How to do a DELETE Pass-Through Query in SQL Server

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.

Continue reading

Get the Language Currently Being Used in SQL Server

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 reading

How to do an INSERT Pass-Through Query in SQL Server

In 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.

Continue reading