删除SQL Server -2008中的行 [英] Delete row in sql server -2008

查看:138
本文介绍了删除SQL Server -2008中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在Sql中有一个奇数问题,问题是这样的:
我有一个名为Resource_Master的表,其中包含诸如:
的字段 ResourceId数字(18,0)
ResourceName varchar(max)
ResourceDescription varchar(max)
ResourceKeyword varchar(max)

现在发生的问题是我实际上有两行具有相同的resourceid,resourcename,resourcedescription,resourcekeyword
例如:
ResourceId ResourceName ResourceName ResourceDesc ResourceKey
13135 xyz abc pqr
13135 xyz abc pqr

我知道我通过不将ResourceId的Identity规范属性设置为yes犯了一个错误,但是现在我大约有20,000行,并且我无法通过编辑行来搜索特定行,并且我想删除该行之一(以上说明),此表除了ResoureId之外没有其他主键.

我想以任何方式删除此行,否则将对我造成严重问题.

拜托,请帮帮我...

提前谢谢.

问候,
Krunal Panchal

Hello everyone,

I have one Odd question in Sql, the question is like this:
I have table called Resource_Master in which there are fields like :
ResourceId numeric(18,0)
ResourceName varchar(max)
ResourceDescription varchar(max)
ResourceKeyword varchar(max)

Now the problem occured is i have one actually two rows with same resourceid,resourcename,resourcedescription,resourcekeyword
e.g.:
ResourceId ResourceName ResourceDesc ResourceKey
13135 xyz abc pqr
13135 xyz abc pqr

I know i have made a mistake, by not setting ResourceId''s Identity specification property to yes, but now i have around 20,000 rows and i cant search a particular row by Editing the rows and i want to delete one of this row (above explained), there is no another primary key for this table except ResoureId.

I want to delete this row anyhow, otherwise it would create a major problem for me..

Please,please help me out...

Thanks in advance.

Regards,
Krunal Panchal

推荐答案

1.在此表中添加一个名为UniqueResourceId
的IDENTITY列 2.执行此查询
1. Add an IDENTITY column to this table called UniqueResourceId
2. Execute this query
DELETE FROM  Resource_Master WHERE UniqueResourceId NOT IN (
SELECT MIN(UniqueResourceId) FROM Resource_Master GROUP BY ResourceId, ResourceName, ResourceDesc, ResourceKey)

3.现在,如果要通过Google搜索

3. Now drop the UniqueResourceId column


= ie7& rls = com.microsoft:en-gb:IE-Address& ie =& oe => this [如何从SQL Server中的表中删除重复的行 [
If you would have googled for this[^], the very first article would have helped you.

Anyways, look at this article.

How to remove duplicate rows from a table in SQL Server[^]


这篇关于删除SQL Server -2008中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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