Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Change database context
Thu, Apr 23 2009 7:36 AMPermanent Link

Dan
Can I change the database context in a script procedure?

Inside a script executed in context of database A, I want to create a table in another
database B for example.

Thanks.
Thu, Apr 23 2009 10:28 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Dan,

> Can I change the database context in a script procedure?

In a script, yes; in a stored procedure, no.

> Inside a script executed in context of database A, I want to create a
> table in another
> database B for example.

In a script or job, you can close the currently opened databse and open a
new one with the USE statement, like this:

 ...
 USE B;
 EXECUTE IMMEDIATE 'CREATE TABLE X .... ';
 USE A;
 ...

--
Fernando Dias
[Team Elevate]

Image