In SQL Server 2005, how can I use database_b, do something, then use the old db database_a in TSQL?

Posted by Yousui on Stack Overflow See other posts from Stack Overflow or by Yousui
Published on 2010-05-25T09:57:42Z Indexed on 2010/05/25 10:01 UTC
Read the original article Hit count: 136

Filed under:
|

Hi guys,

In SQL Server 2005, how can I use database_b, do something, then use the old db database_a in TSQL? The following is my code but there is some problem with it. Who can help me to identity the problem? Great thanks.

DECLARE @old_database_name VARCHAR(200)
SET @old_database_name = db_name()

use mydatabase

create table t1(id int identity(1,1))

use @old_database_name

© Stack Overflow or respective owner

Related posts about sql-server-2005

Related posts about tsql