DYnamic SQL示例 [英] DYnamic SQL examples
问题描述
使用列和表作为参数的动态sql可以使用其他有用的实际生活示例吗?如何使用它?
感谢任何建议和帮助:)
认为
Gabe
/编辑
对于回复,我特别感兴趣的例子不包含管理事务或数据库转换或类似的东西,我正在寻找示例中的代码比例java更复杂一个动态的sql在例如存储过程。
我曾经不得不编写一个Excel导入,其中excel表不像csv文件,但是像矩阵一样布局。所以我不得不处理3个临时表(列,行,内部)的未知数量的列。这些行也是一种简短的树形。听起来很奇怪,但是很有趣。
在SQL Server中,没有机会处理这个没有动态SQL。
I have lately learned what is dynamic sql and one of the most interesting features of it to me is that we can use dynamic columns names and tables. But I cannot think about useful real life examples. The only one that came into my mind is statistical table.
Let`s say that we have table with name, type and created_data. Then we want to have a table that in columns are years from created_data column and in row type and number of names created in years. (sorry for my English)
What can be other useful real life examples of using dynamic sql with column and table as parameters? How do you use it?
Thanks for any suggestions and help :) regards Gabe
/edit Thx for replies, I am particulary interested in examples that do not contain administrative things or database convertion or something like that, I am looking for examples where the code in example java is more complicated than using a dynamic sql in for example stored procedure.
I once had to write an Excel import where the excel sheet was not like a csv file but layed out like a matrix. So I had to deal with a unknown number of columns for 3 temporary tables (columns, rows, "infield"). The rows were also a short form of tree. Sounds weird, but was a fun to do. In SQL Server there was no chance to handle this without dynamic SQL.
这篇关于DYnamic SQL示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!