let's say I have a table with a lot of columns and I want to call same function on every of them (for example MAX
). Is it possible without listing all columns? That is instead of
Select max(col1), max(col2), max(col3)
from table1
write
Select max(col)
for col in table1.columns
from table1
2条答案
按热度按时间6xfqseft1#
There is no out of the box function to do that but since you have dynamic function tagged I assume that you want an example of dynamic code as well.
5n0oy7gb2#
Execute the dynamic query using
sp_executesql
.Hope it's work