dynamic sql in a table-valued function

  • Hi

    I would like to create a table-valued function where the database used is dependant on a variable passed. So for example

    create function dbo.fn_TableFunction(@database as char(5))

    Returns table as

    return

    (

    select

    field1

    , field2

    From

    @database.dbo.tblTable1

    )

    this obviously doesnt work but i dont know of an alternative. I cant use a stored procedure as I want to select the results in another query.

    Thanks in advance

  • this has been resolved

    thanks

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply