sql 2005 不同数据库的数据表复制
sql 2005表的复制有两种:一种就是把整个表复制过去,就好像复制文件并且重命名。别外一种就是把表的内容复制过出.
select * into newtable form oldtable;把oldtabel复制到newtable且newtable不存在,否则出错.;
insert into newtable select * from oldtable把oldtable的内容插入到newtable, newtable一定要存在,才可以复制.
相关文档:
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询“001”课程比“002”课程成绩高的所有学生的学号;
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
fr ......
追加:row_number, rank, dese_rank, ntile
1. row_number: 为查询出来的每一行记录生成一个序号。
SELECT row_number() OVER(ORDER BY field) AS row_n
from tablename;
分页查询:
with t_towtable
as (select row_number over(order by field1) as row_number from tb)
select * from t_rowtable where row_numbe ......
-----------------------------------------------------------------------------------------------------------------------
create table tb(id varchar(3) , pid varchar(3) , name varchar(10))
insert into tb values('001' , null , '广东省')
insert into tb values('002' , '001' , '广州市')
insert i ......
作者:superhasty
2007-11-29
在论坛上常见有朋友抱怨,说SQL Server太吃内存了。这里笔者根据经验简单介绍一下内存相关的调优知识。首先说明一下SQL
Server内存占用由哪几部分组成。SQL Server占用的内存主要由三部分组成:数据缓存(Data
Buffer)、执行缓存(Procedure Cache)、以及SQL Server引擎程序。S ......
分页查询的原理:
这个只能用再Sql2005及以上的版本
DECLARE @pagenum AS INT, @pagesize AS INT
SET @pagenum = 2
SET @pagesize = 3
SELECT *
from (SELECT ROW_NUMBER()&n ......