尝试删除SQL Server中的行时无效的列名称错误 [英] Invalid column name error when trying to delete a row in SQL server
问题描述
当我尝试删除行时,在SQL Server中获取错误。它抱怨的栏目已经存在...
DELETE
来自[dbo]的
。[样本]
WHERE [pk_sample] ='642388'
(受影响的一行)
(1排受影响)
(受影响1排)
(1排)受影响的)
消息207,等级16,状态1,行1
无效的列名称'SampleCondition'。
消息207,等级16,状态1,第1行
无效的列名称'SampleCondition'。
消息207,级别16,状态1,行1
无效的列名称'SampleCondition'。
Msg 207,Level 16,State 1,Line 1
无效的列名'SampleCondition'。
Msg 207,Level 16,状态1,第1行
无效的列名称'SampleCondition'。
消息207,级别16,状态1,行1
无效列名'SampleCondition'。
Msg 207,Level 16,State 1,Line 1
无效的列名称'SampleCondition'。
消息207,级别16,状态1,行1
无效的列名称'SampleCondition'。
我尝试了什么:
我已经尝试检查列是否存在以及值是什么它有..它有一个Null值传递给它...
Getting error in SQL Server when i am trying to delete a row. the column which it is complaining already exists...
DELETE
from [dbo].[sample]
WHERE [pk_sample] = '642388'
(1 row affected)
(1 row affected)
(1 row affected)
(1 row affected)
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SampleCondition'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SampleCondition'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SampleCondition'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SampleCondition'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SampleCondition'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SampleCondition'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SampleCondition'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SampleCondition'.
What I have tried:
I have tried checking the column if it exists and what value it has.. it has a Null value passed into it...
推荐答案
我首先看一下你用来执行那个SQL的代码,您在数据库中设置的任何TRIGGERS:您拥有的消息数量表示您是在循环或类似的情况下执行此操作,并且可能是导致该问题的SQL周围的代码 - 只需发出该命令即可给你一个单独的N行受影响,除非你在删除上有一个TRIGGER试图加载其他东西并且TRIGGER代码有问题。
I'd start by looking at the code you are using to execute that SQL, and any TRIGGERS you have set in the DB: the number of messages you have would indicate that you are doing it in a loop or similar, and it's probably the code around that SQL that is causing the problem - just issuing that command as it stands will give you one single "N rows affected" unless you have a TRIGGER on the delete which is trying to do a load of other things and that TRIGGER code has a problem.
这篇关于尝试删除SQL Server中的行时无效的列名称错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!