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

只谈情不闲聊 提交于 2019-12-12 02:13:24

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/8356244/difference-between-compile-errors-and-run-time-errors-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!