×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

View OK. SP/Function you can try.

You can accurately find out view name by table name.
SELECT VIEW_NAME FROM INFORMATION_SCHEMA.VIEW_TABLE_USAGE WHERE TABLE_NAME= 'Your Table Name'

However, it’s not easy to accurately obtain functions /stored procedures by table name

Anyway, you can try:

DECLARE @TABLE_NAME VARCHAR(100)

SELECT @TABLE_NAME = '%' + 'Your Table Name' + '%'

SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES
WHERE (ROUTINE_TYPE = 'FUNCTION' OR ROUTINE_TYPE = ‘PROCEDURE’) AND ROUTINE_DEFINITION LIKE @TABLE_NAME
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / Looking for a way to do this in SQL server: given a table name, and would like to know a list of stored procedures/View/Function are using this table.
    Thank you.
    • View OK. SP/Function you can try.
      You can accurately find out view name by table name.
      SELECT VIEW_NAME FROM INFORMATION_SCHEMA.VIEW_TABLE_USAGE WHERE TABLE_NAME= 'Your Table Name'

      However, it’s not easy to accurately obtain functions /stored procedures by table name

      Anyway, you can try:

      DECLARE @TABLE_NAME VARCHAR(100)

      SELECT @TABLE_NAME = '%' + 'Your Table Name' + '%'

      SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES
      WHERE (ROUTINE_TYPE = 'FUNCTION' OR ROUTINE_TYPE = ‘PROCEDURE’) AND ROUTINE_DEFINITION LIKE @TABLE_NAME
      • great. the SP/Function seem working but View not..thx.