T-SQL 中的类似形状查询

发布于 2024-08-29 01:38:57 字数 303 浏览 1 评论 0原文

我想编写一个 T-SQL 语句,将数据结构化以加载到 Ado.Net 数据集中,就像使用 ADO SHAPE 命令一样。 T-SQL中有类似的东西吗?

我的想法是从主表中选择多行,并从子表中选择所有相关记录。该数据将被加载到数据集中,然后我将创建关系并使用 GetChildRows()。

最直接的解决方案是从主表中选择记录到临时表中,然后使用“select * from child_table where ParentID in (select Id from #temp)”。但在更复杂的场景中,代码会变得相当难看。

有更好的解决方案吗?

I would like to write a T-SQL statement, that structures data to be loaded into a Ado.Net DataSet like it was possible with the ADO SHAPE command. Is there something similar in T-SQL?

My idea is to select multiple rows from a main table and all related records from a child table. That data would get loaded in to a DataSet and then I would create relations and use GetChildRows().

The most straight forward solution would be to select records from the main table into a temp table and then use "select * from child_table where ParentID in (select Id from #temp)". But in more complex scenarios the code will become quite ugly.

Is there a better solution available?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゃ懵逼小萝莉 2024-09-05 01:38:57

答案很简单:根本不可能! :-(

The answer is quite simple: It's not possible at all! :-(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文