开发者

Use a specific database depending on condition

开发者 https://www.devze.com 2022-12-31 08:40 出处:网络
Can I somehow use a specific database given a specific condition? To clarify I will give a naive example:

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

CASE 
    WHEN @开发者_StackOverflow中文版dbnum = 1 THEN USE Db1
        ELSE USE DefaultDb
END


You can do it with an IF:

IF @dbnum = 1
    USE Db1;
ELSE
    USE DefaultDb;
0

精彩评论

暂无评论...
验证码 换一张
取 消