SQL Server中的编译错误和运行时错误之间的区别? [英] Difference between compile errors and run-time errors in SQL Server?

查看:103
本文介绍了SQL Server中的编译错误和运行时错误之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL Server中的编译错误和运行时错误之间有什么区别?在SQL Server中如何区分这些错误?

What is the difference between compile errors and run-time errors in SQL Server? How these errors are distinguished in SQL Server?

推荐答案

在生成执行计划的过程中会发生编译错误。在生成并执行计划时会发生运行时错误。

compile errors occur during the process of generating an execution plan. Run time errors occur when the plan is generated and is being executed.

唯一的区分两者的方法是是否生成计划AFAIK。

The only way of distinguishing between the two is whether or not a plan is generated AFAIK.

示例

/*Parse Error*/
SELEC * FROM master..spt_values

GO

/*Bind Error*/
SELECT * FROM master..spt_values_

GO


/*Compile time - constant folding error*/
SELECT LOG(0)
FROM master..spt_values

GO

/*Runtime Error*/
DECLARE @Val int = 0
SELECT  LOG(@Val)
FROM master..spt_values

即使其中一个是编译时错误,另一个是运行时错误,后2个错误也会引发完全相同的错误。

The last 2 raise exactly the same error even though one is a compile time error and the other a run time error.

这篇关于SQL Server中的编译错误和运行时错误之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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