SQL脚本来编辑表中的字段 [英] SQL Script to edit a field in a Table

查看:68
本文介绍了SQL脚本来编辑表中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮忙.

我有一个SQL 2008 R2客户记录表,需要编辑每个记录中的字段之一.
例如

表客户"
每个记录中的字段"Analysis3"
我的代码是

Can anyone please help.

I have an SQL 2008 R2 table of customer records and need to edit one of the fields in each reocrd.
E.g

Table "Customers"
Field in each record "Analysis3"
My Code is

select * from SLCustomerAccount
Update SLCustomerAccount
Set AnalysisCode3= 'O21 Merchant/Commercial Shipping'
where AnalysisCode3 = 'C21 Merchant/Commercial Shipping'


我收到此错误消息


I get this Error message

(2291 row(s) affected)
Msg 512, Level 16, State 1, Procedure UpdateCustomerExport, Line 7
Subquery returned more than 1 value. This is not permitted when the
      subquery  follows =, !=, <, <= , >, >= or when the subquery
       is used as an expression.
The statement has been terminated.


请帮忙我的头发少,我一分钟就会把更多的头发拉出来.

谢谢
Stephen


Please help i have little hair and i am pulling more out by the minute.

Thank you
Stephen

推荐答案

您确定SLCustomerAccount是表吗?如果您所做的只是使用您发布的两个语句,那么我认为幕后正在发生一些黑魔法".使用如下所示的语句,可以从存储过程的执行中创建视图:

Are you sure that SLCustomerAccount is a table? If all you are doing is using the two statements you posted, I assume there is some "black magic" going on behind the scenes. Using a statment like the following lets one create a view from the execution of a stored procedure:

CREATE VIEW dbo.SLCustomerAccount
AS
SELECT TOP(100) PERCENT *
FROM OPENROWSET('SQLOLEDB', 'Trusted_Connection=Yes;Server=(local);Database=NameOfTheDatabasse', 'exec UpdateCustomerExport);



这样的视图可能存在问题.您的第一条语句(select语句)可以正常工作,但是对这种视图的更新可能无效.

顺便说一句,在您的问题中,您还提到了一个称为客户"的表,该表不会在您的语句的其他任何地方显示.

问候,

—曼弗雷德(Manfred)



There might be an issue with having a view like that updateable. Your first statement (the select statement) will work fine, but an update on such a view might not be valid.

BTW in your question you also mention some table called "Customer" which does not show up anywhere else in your statements.

Regards,

— Manfred


亲爱的
试试这个

hi dear
try this

Update SLCustomerAccount
Set AnalysisCode3= N'O21 Merchant/Commercial Shipping'
where AnalysisCode3 = N'C21 Merchant/Commercial Shipping'


这篇关于SQL脚本来编辑表中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆