[Macromedia][SQLServer JDBC 驱动程序][SQLServer]无效的对象名称 'column_name'
[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name 'column_name'
在我的 ColdFusion 11 网站(使用 SQL Server 2008 R2)中,以下 cfquery 抛出上述错误:
<cfquery name="deleteGrantModificationItems" datasource="#dsource#">
DELETE col_key FROM myTable
WHERE col_key = <cfqueryPARAM value = "#appkey#" CFSQLType = "CF_SQL_VARCHAR">
</cfquery>
当我 运行 sql 分析器捕获查询时,我得到:
Declare @p1 int
Set @p1=NULL
exec sp_prepexec @p1 output,N'@P1 varchar(8000)',N'DELETE col_key FROM myTable
WHERE col_key = @P1 ','000000001644'
select @p1
当我在查询分析器中 运行 以上内容时,出现以下错误:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'col_key'.
Msg 8180, Level 16, State 1, Procedure sp_prepexec, Line 1
Statement(s) could not be prepared.
我一直找不到错误的原因。
您有一个语法错误,因为您应该使用 DELETE FROM table_name ...
,例如:
<cfquery name="deleteGrantModificationItems" datasource="#dsource#">
DELETE FROM myTable
WHERE col_key = <cfqueryPARAM value = "#appkey#" CFSQLType = "CF_SQL_VARCHAR">
</cfquery>
[ WITH [ ,...n ] ] DELETE
[ TOP ( expression ) [ PERCENT ] ]
[ FROM ]
在我的 ColdFusion 11 网站(使用 SQL Server 2008 R2)中,以下 cfquery 抛出上述错误:
<cfquery name="deleteGrantModificationItems" datasource="#dsource#">
DELETE col_key FROM myTable
WHERE col_key = <cfqueryPARAM value = "#appkey#" CFSQLType = "CF_SQL_VARCHAR">
</cfquery>
当我 运行 sql 分析器捕获查询时,我得到:
Declare @p1 int
Set @p1=NULL
exec sp_prepexec @p1 output,N'@P1 varchar(8000)',N'DELETE col_key FROM myTable
WHERE col_key = @P1 ','000000001644'
select @p1
当我在查询分析器中 运行 以上内容时,出现以下错误:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'col_key'.
Msg 8180, Level 16, State 1, Procedure sp_prepexec, Line 1
Statement(s) could not be prepared.
我一直找不到错误的原因。
您有一个语法错误,因为您应该使用 DELETE FROM table_name ...
,例如:
<cfquery name="deleteGrantModificationItems" datasource="#dsource#">
DELETE FROM myTable
WHERE col_key = <cfqueryPARAM value = "#appkey#" CFSQLType = "CF_SQL_VARCHAR">
</cfquery>
[ WITH [ ,...n ] ] DELETE
[ TOP ( expression ) [ PERCENT ] ]
[ FROM ]