tsql SELECT 语句的结果行集的查询列是否可为空?
考虑以下伪 tsql
table a
{
field1 int,
field2 int NULL
}
table b
{
field1 int,
field3 int
}
create procedure Sp1
As
Select a.field1, a.field2, b.field3
From a inner join b on a.field1 = b.field1
是否可以查询过程 Sp1 来确定结果列是否可以为空? 看来数据集生成器可以实现这一点,对吧?
可以在tsql中完成吗?通过其他方式?
期望的输出:
field1 int, field2 int NULL, field3 int
或者:(
field1, field2 nullable, field3
第一个显然会更好)
谢谢!
Consider the following pseudo-tsql
table a
{
field1 int,
field2 int NULL
}
table b
{
field1 int,
field3 int
}
create procedure Sp1
As
Select a.field1, a.field2, b.field3
From a inner join b on a.field1 = b.field1
Is it possible to query the procedure Sp1 for if the resulting columns can be null or not?
It seems the dataset generator can pull that off right?
Can it be done in tsql? By other means?
Desired output:
field1 int, field2 int NULL, field3 int
Or:
field1, field2 nullable, field3
(The first would obviously be better)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据集生成器将设置 FMTONLY 设置选项。这会导致空结果集返回给客户端,而不是实际运行查询。大多数客户端数据访问技术(例如 ADO.Net< /a>、SQL Native 客户端等)都有方法询问结果集对象(甚至是空对象)并确定有关它们的架构信息。
但我想不出一种方法来实际使用 T-SQL 中的这些信息。从存储过程中获取结果集的唯一方法是 INSERT...EXEC< /a>,但在这种情况下,您必须已经定义了一个表。
The dataset generator will set the FMTONLY set option on. This causes empty result sets to be returned to the client, instead of actually running the queries. Most client data access technologies (e.g. ADO.Net, SQL Native client, etc) have ways of interrogating result set objects (even empty ones) and determining schema information about them.
I can't think of a way to actually consume this information from T-SQL though. The only way of grabbing a result set from a stored procedure is INSERT...EXEC, but in that case, you have to already have a table defined.