SQL2008更新记录 [英] Sql2008 updating a record

查看:82
本文介绍了SQL2008更新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在我的项目中使用sql2008.
在我的一张表中,不能从sql2008编辑环境(在MyTbl编辑前200行窗口中)更新1000条记录中的一条记录,这会出错,但是我可以从QueryAnalizer窗口(使用Sql命令)更新该记录. >
我对此表中的其他记录没有任何问题.

有人可以帮我吗?

Hi,

I am using sql2008 in my project.
In one of my tables one record in 1000 records can not be updated from sql2008 Editing enviroment (In MyTbl Edit Top 200 Row Window) and it makes error, but I can update that record from QueryAnalizer Window (With Sql Commands).

I have no problem with other records in this table.

Can anyone help me with this?

推荐答案

您可以通过右键单击网格然后选择窗格SQL来修改SQL.
使用where子句来缩小结果集.

我担心我可以从QueryAnalizer窗口更新该记录".请提供代码和错误消息,因为您尝试执行的操作可能有问题.
You can modify the SQL by right clicking the grid then selecting pane SQL.
Use a where clause to narrow the result set.

I am worried that "I can update that record from QueryAnalizer Window". Please provide code and error message as there may be a problem with what you are trying to do.


之所以会发生,是因为没有PK或没有唯一的行标识....
检查以下示例

创建表dbo.T
(T VARCHAR(50),
TT VARCHAR(50),
TTT VARCHAR(50)
)

插入T
选择``A'',``AA'',``AAA''UNION ALL
选择``A'',``AA'',``AAA''UNION ALL
选择``B'',``BB'',``BBB''

如果我想更新首个值,即A,它将不允许我从Management Studio中访问,因为没有唯一的标识....但是,如果我修改了最后一个值,即B
,它将允许我
在Queay Analyzer中,您只需提供合适的条件即可....

谢谢
It occurs because when there is no PK or no unique row identification....
Check below example

CREATE TABLE dbo.T
(T VARCHAR(50),
TT VARCHAR(50),
TTT VARCHAR(50)
)

INSERT INTO T
SELECT ''A'',''AA'',''AAA'' UNION ALL
SELECT ''A'',''AA'',''AAA'' UNION ALL
SELECT ''B'',''BB'',''BBB''

If I want to update the firt value i.e. A it won''t allow me from Management Studio coz no unique identification is there....but it will allow me if I modify last one i.e. B

In Queay Analyzer you just provide the criteria which is fine....

Thanks


这篇关于SQL2008更新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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