Sql Server | Get host address of the client connecting to server
SELECT client_net_address, COUNT(*) FROM sys.dm_exec_connections GROUP BY client_net_address
SELECT client_net_address, COUNT(*) FROM sys.dm_exec_connections GROUP BY client_net_address
We have released a free, fast, advertising-free and 100% client side SQL code formatter. Try it now! SQL Formatter.
SELECT [so].[name] AS [Name], User_name([so].[uid]) AS [Owner], User_name([so2].[uid]) AS [Schema], Object_name([so].[parent_obj]) AS [TableName], Objectproperty([so].[id], ‘execisupdatetrigger’) AS [IsUpdate], Objectproperty([so].[id], ‘execisdeletetrigger’) AS [IsDelete], Objectproperty([so].[id], ‘execisinserttrigger’) AS [IsInsert], Objectproperty([so].[id], ‘execisaftertrigger’) AS [IsAfter], Objectproperty([so].[id], ‘execisinsteadoftrigger’) AS [IsInsteadOf], Objectproperty([so].[id], ‘execistriggerdisabled’)…
Here’s a little script in T-SQL to find queries running in our SQL SERVER database: SELECT sqltext.TEXT, res.session_id, res.status, res.command, res.cpu_time, res.total_elapsed_time FROM sys.dm_exec_requests res CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext This script is also useful…
CREATE FUNCTION dbo.MyFunction (@input VARCHAR(200)) RETURNS VARCHAR(200) AS BEGIN DECLARE @WebSite VARCHAR(250) SET @WebSite = @Input SET @WebSite = REPLACE(@WebSite , ‘https://’, ”) SET @WebSite = REPLACE(@WebSite , ‘http://’, ”) SET @WebSite = REPLACE(@WebSite ,…
Often a good example is worth more than 1000 words. Here’s how to run, on Sql Server, one for each / while in Transact Sql. DECLARE @Id INT DECLARE @Name NVARCHAR(50) DECLARE @LastName NVARCHAR(50) DECLARE…