Use a specific database depending on condition

Posted by nimo on Stack Overflow See other posts from Stack Overflow or by nimo
Published on 2010-05-21T15:43:39Z Indexed on 2010/05/21 15:50 UTC
Read the original article Hit count: 110

Filed under:
|
|

Can I somehow use a specific database given a specific condition? To clarify I will give a naive example:

CASE 
    WHEN @dbnum = 1 THEN USE Db1
        ELSE USE DefaultDb
END

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql-server