SQL Server dynamic queries

前端 未结 6 701
盖世英雄少女心
盖世英雄少女心 2021-01-07 04:21

I have 15 stored procedures that return data from a common table and then join that table with a specific table to retrieve inventory.

Example:

Commo         


        
6条回答
  •  没有蜡笔的小新
    2021-01-07 04:36

    An alternative, if the amount of data isn't too large you may want want to consider a user defined function, which can return a table variable which you could use to join to.

    SELECT ....
    FROM tblCommon c
    INNER JOIN dbo.SomeFuntionThatReturnsData(@someparam) s on c.primaryKey = s.foreignKey
    

提交回复
热议问题