×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

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.