基于检索的值中止基于集合的查询 [英] aborting a set based query based on a value retrieved
问题描述
您好,我们经营2016年的企业。 我喜欢从......中选择...到#temp表的能力 特别是随着不断变化的字段列表。 我喜欢sql格式化目标表格。
Hi we run 2016 enterprise. I like the ability to select … into #temp table from … Especially with an ever changing list of fields. I like that sql formats the target table for me.
但是我有一个挑战。 我今天碰到了一个场景,如果在select中遇到特定列中的空值,我可以为中止proc做好准备。 甚至可能超过1列。 我不想事先用非空约束创建表
。 如果在此选择之后的更长期更新发生之前,proc会中止,那将是最好的。 在加载查找空值后,我真的不想从temp中选择开销。
But I have a challenge. I ran into a scenario today where I can make a good case for aborting the proc if a null value in a particular column is encountered in the select. Maybe even in more than 1 column. I don't want to create the table beforehand with a not null constraint. It would be best if the proc aborted before the more permanent updates that follow this select take place. I don't really want the overhead of select from the temp after it is loaded looking for nulls.
是否有一种可接受的/常见的中止方式,因为基于集合的查询在此运行情景?
Is there an accepted/common way of aborting as the set based query is running in this scenario?
推荐答案
如果null,则中止proc值
aborting the proc if a null value
基于SQL / Set的解决方案没有"中止"的概念迭代解决方案中的过程;您必须根据需要过滤数据。
SQL / Set based solution don't have the concept of "aborting" a process as in iterative solutions; you have to filter the data as you need them.
这篇关于基于检索的值中止基于集合的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!