Home Forums SQL Server 2008 SQL Server 2008 - General On the same server, can you use a TABLE-valued user-defined function from another database? RE: On the same server, can you use a TABLE-valued user-defined function from another database?

  • No, types are database bound, and can only be referenced within that database. For example, on my environment:
    USE Sandbox;
    GO
    --This fails
    DECLARE @test-2 Assets.app.OrderItems;
    GO

    USE Assets;
    GO
    --This works
    DECLARE @test-2 app.OrderItems;
    GO

    If 2 or more of your databases both need to be able to use a Custom Data Type, you'll need to create it on both databases. If all of them do, then you'll need to create it on all of them (and I suggest you create it on the model database to, for future databases).

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk