这个查找过程分两步走:
1、找出这列中有相同内容的记录。代码如下:
select
列名
from
表名
group
by
列名
having
count(列名)
>
1
2、把这些有相同内容的记录,查出来。代码如下:
select
列名
from
表名
where
列名
in
(select
列名
from
表名
group
by
列名
having
count(列名)
>
1)
这些我已经调试过了
同意一楼的,可以用视图来处理,将不要的列直接勾选掉,然后select * from视图就行了
用视图生成下,不用写了,单独某列不要是不行的
如果是用在程序里,就用*吧,把不要的列不绑定上去
declare @sql nvarchar(4000),@name_not_need nvarchar(100)
set @name_not_need='不要的字段名'
set @sql='select '
select top 1 @sql=@sql+name from syscolumns where name<>@name_not_need and id=(select id from sysobjects where name='表名')
select @sql=@sql+','+name+' ' from syscolumns where name<>@name_not_need and id=(select id from sysobjects where name='表名')
select @sql=@sql+' from 表名'
exec sp_executesql @sql
没有,只能想其他替代方法