计算表名在存储过程中出现的次数

时间:2018-05-03 17:48:35

标签: sql-server tsql

我试图查找表名在存储过程列表中出现的次数。有一个简单的方法吗?

结果应该像

Sproc name       count of tablename
abc                  5
def                  3
ghi                  4

1 个答案:

答案 0 :(得分:2)

得到答案:)试一试!谢谢。以防万一有人需要:

#include <string>

class Interface
{
public:
    template <class T> bool init(T *_Service) {AttachService(*_Service);}  //This function does other stuff too.
    template <typename T> void AttachService(T _Service) { m_AttachedService<T> = *_Service; }
    template <typename T> T AttachedService() { return m_AttachedService; }
protected:
    template<typename T> static T m_AttachedService;

    class InterfaceListener
    {
        void Received()
        {
            int a = 1;
            std::string b = "hello";
            AttachedService().setA(a);
            m_AttachedService.setB(b);
        };
    };
};

class Service
{
    Service();
    ~Service();
    virtual void init() = 0;
};

class MyService : public Service, public Interface
{
    MyService();
    ~MyService();
    private:
        int A;
        std::string B;
    protected:
        Interface x;
    public:
        void init() { x.init(this);}
        void setA(int a) { A = a; }
        void setB(std::string b) { B = b; }
};

int main();
{
    MyService myserv;
    myserv.init();
}