sql server 2000 语法

本文介绍SQL中临时表的创建与使用方法,包括两种创建方式及如何利用临时表存储查询结果以供后续查询使用。通过实例展示了如何选取特定条件下的数据。

引用:http://zhidao.baidu.com/question/261673548.html

临时表
(1)建立:create table #表名(字段名 类型,字段名2 类型2。。。。) 手动删除:drop table #表名
每一个用户都可以放心地插入、更新、删除表中的数据而不必担心其它的用户使该表中的数据失效,当用户退出sql时该表可以自动删除,
另一种建立方法:create table tempdb..tablename(field1 datatype,field2 datatype....)
(2)本例给出一临时表的最通常用法:在复合查询中存贮查询的结果为之后的查询使用。
选出所有的居住在nashville的艺术家的记录信息:
方法一:create table #temp_info(name char(30),homebase char(40),style char(20),artist_id int)
insert #temp_info select * from artists where homebase='nashville'
select recordings.* from recordings,artists where recordings.artist_id=#temp_info.artist_id
方法二:select artists.* from artists,recordings where artists.homebase='nashville' 

转载于:https://www.cnblogs.com/sode/archive/2011/10/13/2210199.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值