locked
Cannot find either column "dbo" or the user-defined function or aggregate

    Question

  • I have a unit test "Helper" database with a number of stored procs and a handful of UDF's that are used during seeding and test execution in my "Dev" database.  Up to this point, the "helper DB" UDF's have been used by SPs in the helper database, and that seems to work fine.

     

    However, I now want to unit TEST some unit test support functions...  and that causes the error

     

    Sql Error: 'Cannot find either column "dbo" or the user-defined function or aggregate "dbo.udf_unittest_utility_Get_PrevCycleCount_From_ETLCreatedDate", or the name is ambiguous.' (Severity 16, State 1)

     

    Both databases are on my local box where I am local admin, running under a SQLExpress (2005) instance, so it would seem that permissions should be OK.

     

    If I copy the test script that fails to SMS and run it there (connected to the "Dev" database) - it runs fine.

     

    Any suggestions?

     

    TIA,

    Tore.

    Friday, June 27, 2008 7:29 PM

Answers

  • Have you tried prefixing your function call with the database name?

     

    eg

     

    Code Snippet

    SELECT * FROM dev.dbo.udf_your_function ...

     

     

    Or put a USE statement in your script to make sure you're in the right database? eg

     

    USE mydatabase

     

    Unless you create your functions in the master database, then you can only execute them using a two-part name in the database where they live.

     

     

     

     

    Sunday, June 29, 2008 11:19 PM

All replies

  • Moving to a forum where I think they can help.

     

    -Euan

     

    Sunday, June 29, 2008 10:57 PM
  • Have you tried prefixing your function call with the database name?

     

    eg

     

    Code Snippet

    SELECT * FROM dev.dbo.udf_your_function ...

     

     

    Or put a USE statement in your script to make sure you're in the right database? eg

     

    USE mydatabase

     

    Unless you create your functions in the master database, then you can only execute them using a two-part name in the database where they live.

     

     

     

     

    Sunday, June 29, 2008 11:19 PM
  • It was prefixed.  I had copied and pasted the SP name to avoid typos, but after repeating the copy/paste, the problem resolved.  Maybe I did something wrong, but I sure couldn't tell the difference between the first and second attempt, except for what looked like a space after the SP name...

     

    Like I stated, I copied the script from the DB Pro SQL test window to SMS, and the test ran fine (under the database that the tests are run), so it wasn't a case of a simple typo.

     

    Chalking it up to gruff...

    Monday, June 30, 2008 1:27 PM