Jul 10, 2025

fn_my_permissions

 fn_my_permissions ( securable , 'securable_class' )

Value Description
DATABASE   Permissions on the current database
OBJECT Table, View, Stored Procedure, etc.
SCHEMA Database schema
SERVER Server-level permissions

SELECT * FROM fn_my_permissions(NULL, 'DATABASE');

SELECT * FROM fn_my_permissions(NULL, 'SERVER');

SELECT * FROM fn_my_permissions('dbo.YourTableName', 'OBJECT');

Jul 3, 2025

 <?query --

SELECT *  FROM OPENQUERY([PRIME],'

SELECT CT.SERNO TRANSACTION_ID,

   I013_TRXN_DATE,

   caccserno1,

   numberx,

   creditlimit,

   balance, 

   currency,

   custserno,

   customername,

   peopleserno,

   cisoSERNO, 

   I004_AMT_TRXN ORIGINAL_TRANSACTION_AMOUNT,

   AMOUNT,

   CENTERAMOUNT,

   I049_CUR_TRXN,

   name Currency_name,

   name2 Original_currency_name,

   I043A_MERCH_NAME,

   I043B_MERCH_CITY,

   I043C_MERCH_CNT,

   I019_ACQ_COUNTRY,

   I018_MERCH_TYPE ,

   ORIGINATOR,

   STTG

FROM archctransactions CT

LEFT JOIN (

select 

serno caccserno1,

numberx,

creditlimit,

balance, 

currency,

custserno,

STGENERAL STTG

from CACCOUNTS) CACC ON cacc.caccserno1 = ct.caccserno 

LEFT join (

select 

serno custtseno1,

customername,

peopleserno 

from  ccustomers )ccust on ccust.custtseno1 = cacc.custserno

LEFT join (

  select 

serno cisoSERNO, 

I043A_MERCH_NAME,

I043B_MERCH_CITY,

I043C_MERCH_CNT,

I019_ACQ_COUNTRY,

I018_MERCH_TYPE  

from archCISOTRXNS where I018_MERCH_TYPE = ''6051'') CISO

on ct.serno =ciso.cisoSERNO

inner join (select name,numcode from currencies ) cur on cur.numcode = cacc.currency

inner join (select name name2,numcode numcode2 from currencies ) cur2 on cur2.numcode2 = ct.I049_CUR_TRXN

where postdate between ''2022-01-01'' and  ''2022-12-31'' and I018_MERCH_TYPE = ''6051''  ')

--?>

May 6, 2025

Monitoring SQL Server Deadlocks using Extended Events


Extended Events were first introduced in SQL Server 2008, and therefore you will not face any problem implementing them in our environment.

Extended Events is a lightweight performance monitoring feature that enables users to collect data to monitor and troubleshoot problems.

A deadlock is a situation where two or more processes or threads are blocked indefinitely, waiting for each other to release resources that they need to proceed.

Here we are going to observe how to gather deadlock information through Extended Events :

Creating SQL Server Extended Events to Capture Deadlocks using Management Studio

Step 1: First, open SQL Server Management Studio (SSMS) and navigate to Management > Extended Events > Sessions.



 

Step 2: Right-click on Sessions and select New Session.




Step 3: In the new window, provide a name for your event, we will call it SQLWATCH_deadlock in this caseSelect the event to start at the beginning of the server and when the session is created, you can change these settings if necessary.



Step 4:  Go to the Events tab and in the event library textbox type “deadlock” to filter deadlock events:


Step 5: We will select 2 events: Lock_Deadlock (Raised when a request to acquire a lock is cancelled for the victim of a deadlock) and Lock_deadlock_chain (Raised when a request to acquire a lock results in a deadlock. This event is raised for all members of the deadlock).




Step 6: Having both the events chosen, click on the configure button, and a new window will be opened, in this window we will take a snapshot of the sql_text field so that we can view the query that generated the deadlock


Step 7: In the Data Storage tab, select where you want to store the Extended Event data use a file.



Step 8: After that, click on OK to save the Event configuration, we can see that the event is created and is already running.