Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
テーブル名を変数として持つことができる関数をSQL Server 2008に書きたいと思います。
例えば:
create function test(@tbl varchar(50)) .. select * from @tbl ..
変数から SQL ステートメントを実行できます。
関数内:
DECLARE @var AS VARCHAR(500) SET @var = 'SELECT * FROM ' + @tbl EXECUTE (@var)