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?
LVL 1
NigelRocksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.