stockton Posted March 23, 2007 Share Posted March 23, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/43980-solved-mssql-returned-invalid-object-name/ Share on other sites More sharing options...
aurheim Posted March 23, 2007 Share Posted March 23, 2007 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... Quote Link to comment https://forums.phpfreaks.com/topic/43980-solved-mssql-returned-invalid-object-name/#findComment-213524 Share on other sites More sharing options...
stockton Posted March 24, 2007 Author Share Posted March 24, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/43980-solved-mssql-returned-invalid-object-name/#findComment-214145 Share on other sites More sharing options...
stockton Posted March 24, 2007 Author Share Posted March 24, 2007 The solution was to use <database>.<user>.table on the offending select statement Quote Link to comment https://forums.phpfreaks.com/topic/43980-solved-mssql-returned-invalid-object-name/#findComment-214233 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.