如何找出在SQL中填充表的源? [英] How to find out the source which populates the table in SQL ?

查看:96
本文介绍了如何找出在SQL中填充表的源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要找到特定表格在服务器上填充的来源和条件。



我尝试过:



1.我检查了该表的依赖关系。

2.检查是否有任何SP填充它。

3.没有可用的触发器。

4.不,SSIS包可用。

解决方案

这里有一些查询看看哪里/什么连接到你的盒子然后你应该开始缩小桌子的填充位置。



连接列表



  SELECT  *  FROM  sys .dm_exec_connections 





查询列出了最后执行的sql查询中的详细信息 - 来自平方l server - 如何获取在SQL中使用用户名执行的查询的历史记录 - 数据库管理员堆栈交换 [ ^ ]



列表IP地址和上次运行的查询。

  SELECT  sdest.DatabaseName 
,sdes.session_id
,sdes。[ host_name]
,sdes。[program_name]
,sdes.client_interface_name
,sdes.login_name
,sdes.login_time
,sdes.nt_domain
,sdes .nt_user_name
,sdec.client_net_address
,sdec.local_net_address
,sdest.ObjName
,sdest.Query
FROM sys.dm_exec_sessions AS sdes
INNER JOIN sys.dm_exec_connections AS sdec ON sdec.session_id = sdes.session_id
CROSS APPLY
SELECT db_name(dbid) AS DatabaseName
,object_id(objectid) AS ObjName
,ISNULL((
SELECT TEXT AS [processing-instruction(definition)]
FROM sys。 dm_exec_sql_text(sdec.most_recent_sql_handle)
FOR XML PATH(' '
TYPE
),' ' AS 查询

FROM sys.dm_exec_sql_text(sdec.most_recent_sql_handle)
)sdest
ORDER BY sdec.session_id


无权执行

sys.dm_exec_con nections

Need to find the source and conditions through which a particular table populates on server.

What I have tried:

1. I have checked the dependencies on that table.
2. Checked if there is any SP which populates it.
3. No trigger available which does this.
4. No, SSIS package available.

解决方案

Here are a few queries to see where/what is connecting to your box and then you should begin to narrow down where the table is being populated from.

Listing of connections

SELECT * FROM     sys.dm_exec_connections



Query that lists detailed info among that being the last executed sql query - from sql server - how to get History of queries executed with username in SQL - Database Administrators Stack Exchange[^]

Lists IP address and last ran queries.

SELECT sdest.DatabaseName 
    ,sdes.session_id
    ,sdes.[host_name]
    ,sdes.[program_name]
    ,sdes.client_interface_name
    ,sdes.login_name
    ,sdes.login_time
    ,sdes.nt_domain
    ,sdes.nt_user_name
    ,sdec.client_net_address
    ,sdec.local_net_address
    ,sdest.ObjName
    ,sdest.Query
FROM sys.dm_exec_sessions AS sdes
INNER JOIN sys.dm_exec_connections AS sdec ON sdec.session_id = sdes.session_id
CROSS APPLY (
    SELECT db_name(dbid) AS DatabaseName
        ,object_id(objectid) AS ObjName
        ,ISNULL((
                SELECT TEXT AS [processing-instruction(definition)]
                FROM sys.dm_exec_sql_text(sdec.most_recent_sql_handle)
                FOR XML PATH('')
                    ,TYPE
                ), '') AS Query

    FROM sys.dm_exec_sql_text(sdec.most_recent_sql_handle)
    ) sdest
ORDER BY sdec.session_id


Do not have permission to perform "
sys.dm_exec_connections"


这篇关于如何找出在SQL中填充表的源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆