statement “USE @dbname” doesn't work, why? How to do that?

后端 未结 4 1761
轻奢々
轻奢々 2021-01-19 10:36

I\'ve got this t-sql snippet:

DECLARE @db_name varchar(255);
SET @db_name = \'MY_DATABASE\'; -- assuming there is database called \'my_database\'
USE @db_nam         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-19 10:42

    The way I do this is with an if statement:

    if @DBName = 'DB1'
        
    else
        
    

提交回复
热议问题