Sql Server 简单查询 异步服务器更新语句

时间:2022-04-02 03:30:48

//结构:select 子句 [into 子句] from 子句  [where 子句] [group by 子句]  [having 子句] [order by 子句]

select  dept_code,count(*) from oh_corp_info
where create_date>'2006-01-01'
group by dept_code having count(dept_code)>1  order by dept_code

//查询前百分之N的数据

select  top 10 percent  *  from oh_corp_info

//查询语句between用法

select * from oh_corp_info where create_date between '2012-01-02' and '2012-03-01'

//异步服务器获取数据并且插入新表

insert into dbo.assess_company_project_v(a,b,c)
select a,b,c  from opendatasource ('SQLOLEDB','Data Source=IP地址(例192.168.5.117);User ID=服务器;Password=123456;').newcq.dbo.assess_company_project_v

//打开异步服务器连接

[sql] view plaincopy
01.exec sp_configure 'show advanced options',1 
02.reconfigure 
03.exec sp_configure 'Ad Hoc Distributed Queries',1 
04.reconfigure

//使用完成后,关闭Ad Hoc Distributed Queries:

[sql] view plaincopy
01.exec sp_configure 'Ad Hoc Distributed Queries',0 
02.reconfigure 
03.exec sp_configure 'show advanced options',0 
04.reconfigure