select id
from a
where convert(varchar(50),id) not in ('1,2,3')
from a
where convert(varchar(50),id) not in ('1,2,3')
解决方案 »
- 高手请进,兄弟急用!!!!!!!高分回报~~~~~~~
- 有别于行转列,麻烦帮忙看看,谢谢
- 在sql server如何捕捉到用户操作的sql语句?
- 一个sql语句问题——关于用count的默认值问题
- ★请教一个SqlServer性能的问题★
- 我使用数据库sql 2000,其中表A中需要查询字段a 类型为ntext,当数据较少时不会出错。当数据量很大时,超过50万以上,急急
- 寻求一简单sql语句
- 急急急,关于一个存储过程的问题,那位朋友帮忙看一下
- 请教大力、邹等高手!!
- 在线等待,过滤数据,相同数据只取出两条,求SQL语句
- 我想求教 如何用视图显示给定的ID的类别 以及它的所有子类的名字和id ,并且把查询给定的ID的类
- sqlserver中进程堵塞,急(抛分)
from a
where convert(varchar(50),id) not in ('1','2','3')
from a
那里有3
set @idstr = '1,2,3'
create table #t(id int)
set @sql='insert #t select '+replace(@idstr,',',' s union all select ')
exec(@sql)
--@idstr中存在而a表中不存在的id
select * from #t where not exists(select * from a where id=#t.id)
--a表中存在而@idstr中不存在的id
select * from a where not exists(select * from #t where id=a.id)
drop table #t
select @a=id from a
set idstr=replace(idstr,@a,'')
insert into #A select 1
insert into #A select 2set rowcount 1000
select identity(int,1,1) as nid into #t from sysobjects
set rowcount 0declare @idstr varchar(8000)
set @idstr= '1,2,3'select
nid
into
#t1
from
#t
where
nid <= len(@idstr)+2
and
substring(','+@idstr+',',nid,1) = ','
select
id
from
(select
id = substring(','+@idstr+',',nid+1,(select min(nid) from #t1 where nid>a.nid)-nid-1)
from
#t1 a) b
where
id not in(select id from #A) and id is not null
给分