Jump to content

Recommended Posts

I have a php script where I need to access tables in two different MSSQL databases.

The scenario is ..... access 1st database to retrieve data that will be used when calling a StoredProcedure within the 2nd database which will return data with which one can access the 1st database to retrieve more data.

 

If I do both calls to the 1st database by hardcoding info from 2nd database all works well but if I access 1st, call StoredProcedure then attempt to  do a select back on the 1st I get :-

MSSQL returned: Invalid object name 'EarnRate'

EarnRate is an existing table in 1st database.

Please help.

Im just a beginner, but it seams that you havent changed Database from database 1 to 2 before you started to use database 2.

MSSQL returned: Invalid object name 'EarnRate'

probably means that sqlserver could not find the database, probably because it still is using database 1... Just a taught..

 

$conn = mssql_connect('localhost,1433','userid','pw');

$selected_db = mssql_select_db("database1", $con);

DO SOMETHING

$selected_db = mssql_select_db("database2", $con);

THEN SOME MORE...

 

 

It is a little more complicated than that

 

connect and use DB1 to get data for Stored Procedure

connect and use DB2 via Stored Procedure getting data that can be used to

get more data from DB1........and this is the one that fails.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.