简体   繁体   English

SQL Server中的编译错误和运行时错误之间的区别?

[英]Difference between compile errors and run-time errors in SQL Server?

What is the difference between compile errors and run-time errors in SQL Server? SQL Server中的编译错误和运行时错误之间有什么区别? How these errors are distinguished in SQL Server? 在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. 生成计划并执行计划时,会发生运行时错误。

The only way of distinguishing between the two is whether or not a plan is generated AFAIK. 区分两者的唯一方法是是否生成计划。

Examples 例子

/*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

The last 2 raise exactly the same error even though one is a compile time error and the other a run time error. 最后一个2引发完全相同的错误,即使一个是编译时错误,另一个是运行时错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM