使用存储过程中的表名填充数据集 [英] Populate Dataset With Table Names From Stored Procedure

查看:84
本文介绍了使用存储过程中的表名填充数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程,可以返回多个表.

I have a stored procedure that returns multiple tables.

它正确填充了我的数据集,但是命名了我的表[TableTable1Table2,...].

It populates my dataset correctly but it names my tables [Table,Table1,Table2,...].

我可以在数据库层中添加一些东西(到存储过程中)以正确命名表吗?

Is there something I can add in the database layer (to my stored procedure) that will name the tables properly?

推荐答案

您的SP实际上没有返回多张表,而是从表中返回了对列和行的选择,因此没有表名",因此为什么它们的名称分别为table1,table2等.如果它很重要,则可以为每个选择返回一个额外的列,并在该列中填充所需的名称,然后从那里开始使用它.

Your SP is not actually returning multiple tables, its returning a selection of columns and rows from your tables, therefore there is no 'table name', and hence why they are named table1, table2 etc. If its important, you could return an extra column for each selection, and in that column fill it with the desired name and then use it from there.

   select *,'MyTableName1' As [TableName] name from mytablename1
   select *,'MyTableName2' As [TableName] name from mytablename2

这篇关于使用存储过程中的表名填充数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆