Skip to main content
7 events
when toggle format what by license comment
Apr 13, 2022 at 5:21 history edited user1822 CC BY-SA 4.0
added 19 characters in body
Apr 12, 2022 at 22:35 comment added Hart CO "It can't return the name of a table." Sure it can, but the rest of this is good.
Apr 12, 2022 at 20:06 comment added Josh Part @baudot the value is obtained at run time; but to be able to run, the sql engine has to know which tables it will be using before running the query; and the way you want it to work, would require the query to execute for the first table, get all rows, and then go throught all of them running another query for each row. Even if this was possible, it will be VERY expensive.
Apr 12, 2022 at 12:08 comment added user1822 Because a value like 42 or 'foobar' is just that: a value. A table name is an identifier. An identifier and a value are two very different things in SQL
Apr 12, 2022 at 12:04 comment added baudot I'd love to understand WHY the value the CASE evaluates to can't be used as the table name. From the comments on the question so far, it looks like Dynamic SQL can break this rule, though it looks to be ... more involved to get into & start understanding properly.
Apr 12, 2022 at 11:27 vote accept baudot
Apr 12, 2022 at 10:52 history answered user1822 CC BY-SA 4.0