您的位置:首页 > 其它

表变量自动增加字段、主键的定义+exists使用例子

2008-06-09 17:31 197 查看
--表变量定义自动增加字段,定义主键
DECLARE @tmp2 table(id int IDENTITY(1,1),id2 int primary key(id))insert into @tmp2(id2) select top 100 id from book order by idselect * from @tmp2 order by id
--指定一个子查询,测试行是否存在
select t.id from book t where exists(select 1 from @tmp2 where id2=t.id )
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐