select * from a where col1 not in (select col1 from b)
解决方案 »
- 求助SQL问题!
- 谁知道哪里有SQL Server 2008 免费下载的?
- 两个表 连接某一列 数据
- 动态添加列
- 急**********ms sql server 里面企业管理器 里面数据库 名字的后面提示(正在恢复),是什么原因********
- 求computer 以及computer by 的实例,最好有建表以及表数据,谢谢了!
- 紧急求救---我关联两个表时,为什么总提示表中的列与主键或unique约束不匹配
- 各位大侠救命!报mdf文件头不对,PageAudit属性错误!怎么办?
- 怎样在创建表时创建关键字的识别种子自动增量(用SQL Server语句)?请看例:
- 岁月荏苒,还有认识的朋友吗?
- 菜了一问,问一个排序问题?
- 简单的查询语句
create table b(c1 int,c2 int)
declare @c nvarchar(100)
set @c = (select name from syscolumns where id = (select id from sysobjects where name = 'a') and name not in (select name from syscolumns where id = (select id from sysobjects where name = 'b')))
declare @sql nvarchar(200)
set @sql = ' select ' + @c + ' from a'
exec (@sql)
declare @col varchar(4000),@s varchar(4000)
set @col=''
select @col=@col+'+'+''':'''+ '+cast('+name+' as varchar)' from syscolumns where id=object_id('a')
set @col=stuff(@col,1,1,'')
--print @col
set @s='select a.* from a where '+@col+' not in (select '+@col+'from b ) '
exec(@s)