数据库的一道应用题,求解!

jl_lsj 2007-07-21 10:32:55
题目有点忘了,大概就是这个意思:
有服务器server1,数据库database1,表table1,表里有字段,id(int),name(varchar),addtime(datetime)。还有一个服务器server2,也有数据库database1,表table2,表里有字段,id(int),name(varchar),addtime(datetime)。
问题:
A:用什么连接方式、如何连接能把两个服务器上的表里的数据全部显示到一个数据源(或一个表上)。
B:写出10-20之间的10条数据,id有可能不连续。
C:根据B能写出几种查询方式,比较各自的优点。
D:根据B的查询情况,写一个分页的存储过程,参数@PageSize(int),@page(int)。写出当前页的记录数,总行数,当前页数。
...全文
358 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
blue_lw 2007-07-24
  • 打赏
  • 举报
回复
select top 10 * from(select top 20 * from table order by id desc) a
gxqianqin 2007-07-23
  • 打赏
  • 举报
回复
JJMM连接
jl_lsj 2007-07-23
  • 打赏
  • 举报
回复
select * into table1 from
openrowset('sqloledb','IP';'sa';'','select * from database1.dbo.table2')a

这种连接方式叫什么呀?
liufengno1 2007-07-22
  • 打赏
  • 举报
回复
select top 10 id from balance where id > (select max(id) from (select top 10 id from balance) t)
昵称被占用了 2007-07-22
  • 打赏
  • 举报
回复
楼上:
有top,子查询里面可以有order by的
xeppp 2007-07-22
  • 打赏
  • 举报
回复
面试题 楼上大哥,子查询里面可以有order by么,开眼了
beijinghunansdj 2007-07-22
  • 打赏
  • 举报
回复
1.select top 10 * from table where id in(select top 20 * from table order by id desc)
2.select top 20 * into #table from table desc id
select top 10 from #table
3.select top 50% * from table where id not in(select top 20 * from table order by id asc)

俺写的咯~大家来评评~没试过~主要看思路看思路~呵呵
budong0000 2007-07-22
  • 打赏
  • 举报
回复
......mark
xiaoku 2007-07-21
  • 打赏
  • 举报
回复
等等...
mephistophelse 2007-07-21
  • 打赏
  • 举报
回复
关注
fa_ge 2007-07-21
  • 打赏
  • 举报
回复
下面的,等高手來答吧
fa_ge 2007-07-21
  • 打赏
  • 举报
回复
B:写出10-20之间的10条数据,id有可能不连续。

--------------
select top 10 * from table1
where id not in(select top 10 id from table1 order by id)
order by id
fa_ge 2007-07-21
  • 打赏
  • 举报
回复
A:用什么连接方式、如何连接能把两个服务器上的表里的数据全部显示到一个数据源(或一个表上)。
-----------

select * into table1 from
openrowset('sqloledb','IP';'sa';'','select * from database1.dbo.table2')a
jl_lsj 2007-07-21
  • 打赏
  • 举报
回复
主要就是第一个问题不明白,不知道怎么查询两个数据库的数据,后三问比较简单一点了。

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧