短信 'Invalid column name'
SMSS 'Invalid column name'
在你斥责我'this has been asked here:'之前,我想指出我确实做到了google。在某些情况下,我什至去了第 3 页。 不寒而栗
所以这是交易:
我正在尝试审核我们拥有的数据库,为多个 table 设置 UPDATE
、INSERT
、DELETE
语句的触发器。已成功创建并链接触发器。每个触发器执行一个存储过程,将所需数据插入我们的 tick_audit table.
此信息是:
- user_account;存储 谁 改变了什么
- client_id;存储哪个客户的数据发生了变化
- date_time;编辑日期
- table_name; table 更改的名称
- table_record_id;已更改记录的 id
- 描述; 为什么 更改了某些内容
- remote_ip_address;这样我们就可以密切关注发生变化的地方(内部或外部)
table还有一个PRIMARY_KEY、AUTO_INCREMENTid字段。
当我尝试创建存储过程时
create procedure update_tick_user
@UserId varchar(32),
@ClientId varchar(32),
@Table varchar(64),
@TableRecord varchar(512),
@Descr varchar(128),
@RemoteIP varchar(16)
as
begin
insert into tick_audit ('user_account', 'client_id', 'date_time', 'table_name', 'table_record_id', 'descr', 'remote_ip_address')
values
(@UserId, @ClientId, getdate(), @Table, @TableRecord, @Descr, @RemoteIP)
end;
我收到以下错误:
Msg 207, Level 16, State 1, Procedure update_tick_user, Line 10
Invalid column name 'user_account'.
对每一列重复此操作。当我运行
exec sp_columns tick_audit
我从 tick_audit 中获取了所有列,甚至将它们的名称复制到列字段中进行插入,我也遇到了上述错误。当我只是 运行
时,我什至会遇到错误
insert into tick_audit
('user_account', 'client_id', 'date_time', 'table_name', 'table_record_id', 'descr', 'remote_ip_address')
values
('', '', getdate(), '', '', '', '')
每当我尝试在不同的 table 上插入、更新或删除时,我都没有收到任何错误。如果我的 table 或某些超级秘密的骗局、仪式式的方法有问题,我有什么办法可以查明吗?
这是我到目前为止尝试过的方法:
- 放下table(在我脚下,很多很多次),重新创建它。
- Google三个小时
- 问我的同事
- 戴上我的思考帽
- 检查列是否确实存在(通过 exec,select)
祈祷,希望有人能帮助我。
不要在列名周围使用单引号。
create procedure update_tick_user
@UserId varchar(32),
@ClientId varchar(32),
@Table varchar(64),
@TableRecord varchar(512),
@Descr varchar(128),
@RemoteIP varchar(16)
as
begin
insert into tick_audit (user_account, client_id, date_time, table_name, table_record_id, descr, remote_ip_address)
values
(@UserId, @ClientId, getdate(), @Table, @TableRecord, @Descr, @RemoteIP)
end;
删除'
使insert
如下
insert into tick_audit (user_account, client_id, date_time, table_name, table_record_id, descr, remote_ip_address)
values (@UserId, @ClientId, getdate(), @Table, @TableRecord, @Descr, @RemoteIP)
使用方括号代替引号:
insert into tick_audit ([user_account], [client_id], [date_time], [table_name], [table_record_id], [descr], [remote_ip_address])
values (@UserId, @ClientId, getdate(), @Table, @TableRecord, @Descr, @RemoteIP)
单引号用于文字。要分隔对象名称,您应该使用方括号或双引号,但只有当 QUOTED_IDENTIFIER
设置为 ON
.
时才可以使用双引号
在你斥责我'this has been asked here:'之前,我想指出我确实做到了google。在某些情况下,我什至去了第 3 页。 不寒而栗
所以这是交易:
我正在尝试审核我们拥有的数据库,为多个 table 设置 UPDATE
、INSERT
、DELETE
语句的触发器。已成功创建并链接触发器。每个触发器执行一个存储过程,将所需数据插入我们的 tick_audit table.
此信息是:
- user_account;存储 谁 改变了什么
- client_id;存储哪个客户的数据发生了变化
- date_time;编辑日期
- table_name; table 更改的名称
- table_record_id;已更改记录的 id
- 描述; 为什么 更改了某些内容
- remote_ip_address;这样我们就可以密切关注发生变化的地方(内部或外部)
table还有一个PRIMARY_KEY、AUTO_INCREMENTid字段。
当我尝试创建存储过程时
create procedure update_tick_user
@UserId varchar(32),
@ClientId varchar(32),
@Table varchar(64),
@TableRecord varchar(512),
@Descr varchar(128),
@RemoteIP varchar(16)
as
begin
insert into tick_audit ('user_account', 'client_id', 'date_time', 'table_name', 'table_record_id', 'descr', 'remote_ip_address')
values
(@UserId, @ClientId, getdate(), @Table, @TableRecord, @Descr, @RemoteIP)
end;
我收到以下错误:
Msg 207, Level 16, State 1, Procedure update_tick_user, Line 10 Invalid column name 'user_account'.
对每一列重复此操作。当我运行
exec sp_columns tick_audit
我从 tick_audit 中获取了所有列,甚至将它们的名称复制到列字段中进行插入,我也遇到了上述错误。当我只是 运行
时,我什至会遇到错误insert into tick_audit
('user_account', 'client_id', 'date_time', 'table_name', 'table_record_id', 'descr', 'remote_ip_address')
values
('', '', getdate(), '', '', '', '')
每当我尝试在不同的 table 上插入、更新或删除时,我都没有收到任何错误。如果我的 table 或某些超级秘密的骗局、仪式式的方法有问题,我有什么办法可以查明吗?
这是我到目前为止尝试过的方法:
- 放下table(在我脚下,很多很多次),重新创建它。
- Google三个小时
- 问我的同事
- 戴上我的思考帽
- 检查列是否确实存在(通过 exec,select)
祈祷,希望有人能帮助我。
不要在列名周围使用单引号。
create procedure update_tick_user
@UserId varchar(32),
@ClientId varchar(32),
@Table varchar(64),
@TableRecord varchar(512),
@Descr varchar(128),
@RemoteIP varchar(16)
as
begin
insert into tick_audit (user_account, client_id, date_time, table_name, table_record_id, descr, remote_ip_address)
values
(@UserId, @ClientId, getdate(), @Table, @TableRecord, @Descr, @RemoteIP)
end;
删除'
使insert
如下
insert into tick_audit (user_account, client_id, date_time, table_name, table_record_id, descr, remote_ip_address)
values (@UserId, @ClientId, getdate(), @Table, @TableRecord, @Descr, @RemoteIP)
使用方括号代替引号:
insert into tick_audit ([user_account], [client_id], [date_time], [table_name], [table_record_id], [descr], [remote_ip_address])
values (@UserId, @ClientId, getdate(), @Table, @TableRecord, @Descr, @RemoteIP)
单引号用于文字。要分隔对象名称,您应该使用方括号或双引号,但只有当 QUOTED_IDENTIFIER
设置为 ON
.