Use a specific database depending on condition
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;
精彩评论