February 8, 2006 at 7:46 am
I've created a batch file that runs various osql statements.
It runs a create tables scripts and then things like create views, create stored procedures, etc.
My problem comes in when I run a command to compile a trigger (as part of entire process).
Strange circumstances...When running the entire batch file, it fails, (Invalid object name). Run the command itself, it works fine.
I have SP4 as there was a problem noted that it had issues with Invalid object name and osql.
At any rate, I'm really stumped and could use some good, fresh ideas on this one.
Thanks and I do appreciate the help.
February 8, 2006 at 11:52 am
Doug,
There are usually 2 reasons for Invalid Object Name when you are sure the object really exists
1. You are in the wrong database. If you don't specify the database name during the connection then it will be a default database of the user executing the connection. If your batch and individual statement have different people connecting, it will be the case. Example: when you execute the command itself with Windows Integrated (-E) authentication it will be your Windows login who is connecting. The batch executes under (I suppose) Task Scheduler and may have other credentials specified (mylocaluser, for example)
2. If you do specify the database name and still your command and the batch are using different credentials for Integrated Authentication (see #1) then because you say your script create objects, they will be created as MyUser.MyObject unless you specify dbo.MyObject. When another connection tries to connect to this object it will be MyAnotherConnectionUser.MyObject it will try to access, followed by dbo.MyObject If both not found, you will get this error.
Regards,Yelena Varsha
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply