• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Embedded SQL Database Reference

Experts,

I have a program where I'm attempting to execute a SQL query that references a table that exists on another database.  It's the last line before the "if":

            Sql = Sql & "FROM CCLCache.dbo.CustomersExported)"

It's giving me the error "invalid object name" for that table, but I know it exists in that database.  What more do I need?
0
NigelRocks
Asked:
NigelRocks
  • 3
  • 2
1 Solution
 
Daniel WilsonCommented:
Are you sure it belongs to the DBO schema?

And what is the rest of your SQL statement?

And is the database on the same server as the one against which you're actually executing the statement?
0
 
NigelRocksAuthor Commented:
Yes, the database is on the same server.

Dang, I thought I'd attached the snippet...
        Sql = "SELECT cu_acct_num, Customer_Id, Acct_Type_Id, Cu_Name "
        Sql = Sql & "FROM Customer "
        If vExcludeExported Then 'The table used here, is now on local SQL server, must change query to work
            Sql = Sql & "WHERE cu_acct_num "
            Sql = Sql & "NOT IN (SELECT CustomerId "
            Sql = Sql & "FROM CCLCache.dbo.CustomersExported)"
        End If

Open in new window

0
 
Daniel WilsonCommented:
Do you get the same error if you execute the query in SSMS / Query Analyzer?
0
 
NigelRocksAuthor Commented:
No, it works perfectly there,.
0
 
Daniel WilsonCommented:
When you try it in SSMS / Query Analyzer, are you using the same credentials your application uses?

It could be a matter of rights on the CCLCache database.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now