Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Commands in Stored Procedures across Databases

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-10-12 : 07:47:17
Martin writes "I have a problem with stored procedures in SQL 2000 that I hope you can help with.

I have two database lets say DB1 and DB2. In DB1 there is a stored procedure SP1 that calls another stored procedure SP2 in the same database. A specific parameter being passed from SP1 to SP2. SP2 calls a third stored procedure SP3 that resides in DB2 and passes the same parameter to SP3. The problem I have is that if SP3 contains a SELECT statement that says gets records from a table in DB2 that match the migrated parameter there is no problem; however if it contains an INSERT INTO statement to insert the parameter into a table this statement executes with no error (@@ERROR = 0) but does not insert the parameter into the respective database table in DB2 i.e. no new record is created. It seems the SELECT statement works, yet the INSERT INTO statement does not. Both databases have the same permissions configured.

Would you know if this is a bug in SQL 2000 or if there is something specifically I need to do to get the INSERT INTO statement functioning in the above scenario."

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-12 : 07:59:28
Most probably you do not have appropriate rights for these commands on the differens servers.
Also, why do you feel the need to use dynamic SQL as parameter?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -