Inserting Master database data into my database table I put a trigger on one table on update, and I want to insert the last 15 executed queries into a table. Last executed queries are in the MASTER database as

SELECT top(15) dest.text AS [Query]
    FROM sys.dm_exec_query_stats AS deqs

   CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
      --inner join  sys.sysprocesses
     -- on sys.sysprocesses.sql_handle=deqs.sql_handle

      ORDER BY deqs.last_execution_time DESC


How can I insert these 15 queries into my database table as string? The trigger I am using is like this.

ALTER TRIGGER [dbo].[uom_cu]
ON  [dbo].[saleExpStockID] after update

AS 

INSERT INTO zzuomupdate(date_cu, Query_r) 
VALUES(getdate(), (SELECT top(15) dest.text AS [Query]
    FROM master.sys.dm_exec_query_stats AS deqs

   CROSS APPLY master.sys.dm_exec_sql_text(deqs.sql_handle) AS dest

      ORDER BY deqs.last_execution_time DESC))
I very seriously question the use of a trigger here.  Your trigger is going to dramatically slow down the updates of your table.  That being said your query should look more like this:

INSERT INTO zzuomupdate(date_cu, Query_r) 
SELECT top(15) getdate(), dest.text AS [Query]
FROM master.sys.dm_exec_query_stats AS deqs
CROSS APPLY master.sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.last_execution_time DESC


The way you had it you were trying to pull 15 rows worth of information into a single column and that just doesn't work.  The INSERT INTO SELECT syntax is the way to go here.