锘??xml version="1.0" encoding="utf-8" standalone="yes"?>99视频一区,国产精品三级久久久久久电影,欧美先锋影音http://www.shnenglu.com/elva/category/5703.htmlzh-cnMon, 19 May 2008 22:47:32 GMTMon, 19 May 2008 22:47:32 GMT60綺懼SQL璇彞http://www.shnenglu.com/elva/archive/2007/12/06/37896.html鍙跺瓙鍙跺瓙Thu, 06 Dec 2007 03:19:00 GMThttp://www.shnenglu.com/elva/archive/2007/12/06/37896.htmlhttp://www.shnenglu.com/elva/comments/37896.htmlhttp://www.shnenglu.com/elva/archive/2007/12/06/37896.html#Feedback0http://www.shnenglu.com/elva/comments/commentRss/37896.htmlhttp://www.shnenglu.com/elva/services/trackbacks/37896.html璇存槑錛氬鍒惰〃(鍙鍒剁粨鏋?婧愯〃鍚嶏細a 鏂拌〃鍚嶏細b) 

SQL: select * into b from a where 1<>1 

璇存槑錛氭嫹璐濊〃(鎷瘋礉鏁版嵁,婧愯〃鍚嶏細a 鐩爣琛ㄥ悕錛歜) 

SQL: insert into b(a, b, c) select d,e,f from b; 

璇存槑錛氭樉紺烘枃绔犮佹彁浜や漢鍜屾渶鍚庡洖澶嶆椂闂?nbsp;

SQL: select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b 

璇存槑錛氬榪炴帴鏌ヨ(琛ㄥ悕1錛歛 琛ㄥ悕2錛歜) 

SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c 

璇存槑錛氭棩紼嬪畨鎺掓彁鍓嶄簲鍒嗛挓鎻愰啋 

SQL: select * from 鏃ョ▼瀹夋帓 where datediff('minute',f寮濮嬫椂闂?getdate())>5 

璇存槑錛氫袱寮犲叧鑱旇〃錛屽垹闄や富琛ㄤ腑宸茬粡鍦ㄥ壇琛ㄤ腑娌℃湁鐨勪俊鎭?nbsp;

SQL: 

delete from info where not exists ( select * from infobz where info.infid=infobz.infid ) 

璇存槑錛?- 

SQL: 

SELECT A.NUM, A.NAME, B.UPD_DATE, B.PREV_UPD_DATE 

FROM TABLE1, 

(SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE 

FROM (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND 

FROM TABLE2 

WHERE TO_CHAR(UPD_DATE,'YYYY/MM') = TO_CHAR(SYSDATE, 'YYYY/MM')) X, 

(SELECT NUM, UPD_DATE, STOCK_ONHAND 

FROM TABLE2 

WHERE TO_CHAR(UPD_DATE,'YYYY/MM') = 

TO_CHAR(TO_DATE(TO_CHAR(SYSDATE, 'YYYY/MM') || '/01','YYYY/MM/DD') - 1, 'YYYY/MM') ) Y, 

WHERE X.NUM = Y.NUM 錛?錛?nbsp;

AND X.INBOUND_QTY + NVL(Y.STOCK_ONHAND,0) <> X.STOCK_ONHAND ) B 

WHERE A.NUM = B.NUM 

璇存槑錛?- 

SQL: 

select * from studentinfo where not exists(select * from student where studentinfo.id=student.id) and 緋誨悕縐?'"&strdepartmentname&"' and 涓撲笟鍚嶇О='"&strprofessionname&"' order by 鎬у埆,鐢熸簮鍦?楂樿冩繪垚緇?nbsp;

璇存槑錛?nbsp;

浠庢暟鎹簱涓幓涓騫寸殑鍚勫崟浣嶇數璇濊垂緇熻(鐢佃瘽璐瑰畾棰濊春鐢靛寲鑲ユ竻鍗曚袱涓〃鏉ユ簮錛?nbsp;

SQL: 

SELECT a.userper, a.tel, a.standfee, TO_CHAR(a.telfeedate, 'yyyy') AS telyear, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '01', a.factration)) AS JAN, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '02', a.factration)) AS FRI, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '03', a.factration)) AS MAR, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '04', a.factration)) AS APR, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '05', a.factration)) AS MAY, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '06', a.factration)) AS JUE, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '07', a.factration)) AS JUL, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '08', a.factration)) AS AGU, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '09', a.factration)) AS SEP, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '10', a.factration)) AS OCT, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '11', a.factration)) AS NOV, 

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '12', a.factration)) AS DEC 

FROM (SELECT a.userper, a.tel, a.standfee, b.telfeedate, b.factration 

FROM TELFEESTAND a, TELFEE b 

WHERE a.tel = b.telfax) a 

GROUP BY a.userper, a.tel, a.standfee, TO_CHAR(a.telfeedate, 'yyyy') 

璇存槑錛氬洓琛ㄨ仈鏌ラ棶棰橈細 

SQL: select * from a left inner join b on a.a=b.b right inner join c on a.a=c.c inner join d on a.a=d.d where ..... 

璇存槑錛氬緱鍒拌〃涓渶灝忕殑鏈嬌鐢ㄧ殑ID鍙?nbsp;

SQL: 

SELECT (CASE WHEN EXISTS(SELECT * FROM Handle b WHERE b.HandleID = 1) THEN MIN(HandleID) + 1 ELSE 1 END) as HandleID 

FROM Handle 

WHERE NOT HandleID IN (SELECT a.HandleID - 1 FROM Handle a)

====================================

SQL璇彞鎶宸?br>1銆佷竴涓猄QL璇彞鐨勯棶棰?琛屽垪杞崲
   select * from v_temp
涓婇潰鐨勮鍥劇粨鏋滃涓?
user_name role_name
-------------------------
緋葷粺綆$悊鍛?綆$悊鍛?
feng 綆$悊鍛?
feng 涓鑸敤鎴?
test 涓鑸敤鎴?
鎯蟲妸緇撴灉鍙樻垚榪欐牱:
user_name role_name
---------------------------
緋葷粺綆$悊鍛?綆$悊鍛?
feng 綆$悊鍛?涓鑸敤鎴?
test 涓鑸敤鎴?br>===================
create table a_test(name varchar(20),role2 varchar(20))
insert into a_test values('鏉?,'綆$悊鍝?)
insert into a_test values('寮?,'綆$悊鍝?)
insert into a_test values('寮?,'涓鑸敤鎴?)
insert into a_test values('甯?,'涓鑸敤鎴?)

create function join_str(@content varchar(100))
returns varchar(2000)
as
begin
declare @str varchar(2000)
set @str=''
select @str=@str+','+rtrim(role2) from a_test where [name]=@content
select @str=right(@str,len(@str)-1)
return @str
end
go

--璋冪敤錛?br>select [name],dbo.join_str([name]) role2 from a_test group by [name]

--select distinct name,dbo.uf_test(name) from a_test

2銆佹眰鍔╋紒蹇熸瘮杈冪粨鏋勭浉鍚岀殑涓よ〃
緇撴瀯鐩稿悓鐨勪袱琛紝涓琛ㄦ湁璁板綍3涓囨潯宸﹀彸錛屼竴琛ㄦ湁璁板綍2涓囨潯宸﹀彸錛屾垜鎬庢牱蹇熸煡鎵句袱琛ㄧ殑涓嶅悓璁板綍錛?br>============================
緇欎綘涓涓祴璇曟柟娉曪紝浠巒orthwind涓殑orders琛ㄥ彇鏁版嵁銆?br>select * into n1 from orders
select * into n2 from orders

select * from n1
select * from n2

--娣誨姞涓婚敭錛岀劧鍚庝慨鏀筺1涓嫢騫插瓧孌電殑鑻ュ共鏉?br>alter table n1 add constraint pk_n1_id primary key (OrderID)
alter table n2 add constraint pk_n2_id primary key (OrderID)

select OrderID from (select * from n1
union
select * from n2) a group by OrderID having count(*) > 1

搴旇鍙互錛岃屼笖灝嗕笉鍚岀殑璁板綍鐨処D鏄劇ず鍑烘潵銆?br>涓嬮潰鐨勯傜敤浜庡弻鏂硅褰曚竴鏍風殑鎯呭喌錛?/p>

select * from n1 where orderid in
(
select OrderID from (select * from n1
union
select * from n2) a group by OrderID having count(*) > 1
)
鑷充簬鍙屾柟浜掍笉瀛樺湪鐨勮褰曟槸姣旇緝濂藉鐞嗙殑
--鍒犻櫎n1,n2涓嫢騫叉潯璁板綍
delete from n1 where orderID in ('10728','10730')
delete from n2 where orderID in ('11000','11001')

--*************************************************************
-- 鍙屾柟閮芥湁璇ヨ褰曞嵈涓嶅畬鍏ㄧ浉鍚?br>select * from n1 where orderid in
(
select OrderID from (select * from n1
union
select * from n2) a group by OrderID having count(*) > 1
)
union
--n2涓瓨鍦ㄤ絾鍦╪1涓笉瀛樼殑鍦?0728,10730
select * from n1 where OrderID not in (select OrderID from n2)
union
--n1涓瓨鍦ㄤ絾鍦╪2涓笉瀛樼殑鍦?1000,11001
select * from n2 where OrderID not in (select OrderID from n1)
3.
鍥涚鏂規硶鍙栬〃閲宯鍒癿鏉$邯褰曪細

1.
select top m * into 涓存椂琛?鎴栬〃鍙橀噺) from tablename order by columnname -- 灝唗op m絎旀彃鍏?br>set rowcount n
select * from 琛ㄥ彉閲?order by columnname desc


2.
select top n * from
(select top m * from tablename order by columnname) a
order by columnname desc


3.濡傛灉tablename閲屾病鏈夊叾浠杋dentity鍒楋紝閭d箞錛?br>select identity(int) id0,* into #temp from tablename

鍙杗鍒癿鏉$殑璇彞涓猴細
select * from #temp where id0 >=n and id0 <= m

濡傛灉浣犲湪鎵цselect identity(int) id0,* into #temp from tablename榪欐潯璇彞鐨勬椂鍊欐姤閿?閭f槸鍥犱負浣犵殑DB涓棿鐨剆elect into/bulkcopy灞炴ф病鏈夋墦寮瑕佸厛鎵ц錛?br>exec sp_dboption 浣犵殑DB鍚嶅瓧,'select into/bulkcopy',true


4.濡傛灉琛ㄩ噷鏈塱dentity灞炴э紝閭d箞綆鍗曪細
select * from tablename where identitycol between n and m
5.濡備綍鍒犻櫎涓涓〃涓噸澶嶇殑璁板綍錛?br>create table a_dist(id int,name varchar(20))

insert into a_dist values(1,'abc')
insert into a_dist values(1,'abc')
insert into a_dist values(1,'abc')
insert into a_dist values(1,'abc')

exec up_distinct 'a_dist','id'

select * from a_dist

create procedure up_distinct(@t_name varchar(30),@f_key varchar(30))
--f_key琛ㄧず鏄垎緄勫瓧孌碉箰鍗充富閸靛瓧孌?br>as
begin
declare @max integer,@id varchar(30) ,@sql varchar(7999) ,@type integer
select @sql = 'declare cur_rows cursor for select '+@f_key+' ,count(*) from ' +@t_name +' group by ' +@f_key +' having count(*) > 1'
exec(@sql)
open cur_rows
fetch cur_rows into @id,@max
while @@fetch_status=0
begin
select @max = @max -1
set rowcount @max
select @type = xtype from syscolumns where id=object_id(@t_name) and name=@f_key
if @type=56
select @sql = 'delete from '+@t_name+' where ' + @f_key+' = '+ @id
if @type=167
select @sql = 'delete from '+@t_name+' where ' + @f_key+' = '+''''+ @id +''''
exec(@sql)
fetch cur_rows into @id,@max
end
close cur_rows
deallocate cur_rows
set rowcount 0
end

select * from systypes
select * from syscolumns where id = object_id('a_dist')

6.鏌ヨ鏁版嵁鐨勬渶澶ф帓搴忛棶棰橈紙鍙兘鐢ㄤ竴鏉¤鍙ュ啓錛?
CREATE TABLE hard (qu char (11) ,co char (11) ,je numeric(3, 0))

insert into hard values ('A','1',3)
insert into hard values ('A','2',4)
insert into hard values ('A','4',2)
insert into hard values ('A','6',9)
insert into hard values ('B','1',4)
insert into hard values ('B','2',5)
insert into hard values ('B','3',6)
insert into hard values ('C','3',4)
insert into hard values ('C','6',7)
insert into hard values ('C','2',3)


瑕佹眰鏌ヨ鍑烘潵鐨勭粨鏋滃涓嬶細

qu co je
----------- ----------- -----
A 6 9
A 2 4
B 3 6
B 2 5
C 6 7
C 3 4


灝辨槸瑕佹寜qu鍒嗙粍錛屾瘡緇勪腑鍙杍e鏈澶х殑鍓?浣嶏紒錛?br>鑰屼笖鍙兘鐢ㄤ竴鍙ql璇彞錛侊紒錛?br>select * from hard a where je in (select top 2 je from hard b where a.qu=b.qu order by je)
7.姹傚垹闄ら噸澶嶈褰曠殑sql璇彞錛?
鎬庢牱鎶婂叿鏈夌浉鍚屽瓧孌電殑綰綍鍒犻櫎錛屽彧鐣欎笅涓鏉°?br>渚嬪錛岃〃test閲屾湁id,name瀛楁
濡傛灉鏈塶ame鐩稿悓鐨勮褰?鍙暀涓嬩竴鏉★紝鍏朵綑鐨勫垹闄ゃ?br>name鐨勫唴瀹逛笉瀹氾紝鐩稿悓鐨勮褰曟暟涓嶅畾銆?br>鏈夋病鏈夎繖鏍風殑sql璇彞錛?br>==============================
A:涓涓畬鏁寸殑瑙e喅鏂規錛?/p>

灝嗛噸澶嶇殑璁板綍璁板叆temp1琛?
select [鏍囧織瀛楁id],count(*) into temp1 from [琛ㄥ悕]
group by [鏍囧織瀛楁id]
having count(*)>1

2銆佸皢涓嶉噸澶嶇殑璁板綍璁板叆temp1琛?
insert temp1
select [鏍囧織瀛楁id],count(*) from [琛ㄥ悕]
group by [鏍囧織瀛楁id]
having count(*)=1

3銆佷綔涓涓寘鍚墍鏈変笉閲嶅璁板綍鐨勮〃錛?br>select * into temp2 from [琛ㄥ悕]
where 鏍囧織瀛楁id in(select 鏍囧織瀛楁id from temp1)

4銆佸垹闄ら噸澶嶈〃:
delete [琛ㄥ悕]

5銆佹仮澶嶈〃錛?br>insert [琛ㄥ悕]
select * from temp2

6銆佸垹闄や復鏃惰〃:
drop table temp1
drop table temp2
================================
B:
create table a_dist(id int,name varchar(20))

insert into a_dist values(1,'abc')
insert into a_dist values(1,'abc')
insert into a_dist values(1,'abc')
insert into a_dist values(1,'abc')

exec up_distinct 'a_dist','id'

select * from a_dist

create procedure up_distinct(@t_name varchar(30),@f_key varchar(30))
--f_key琛ㄧず鏄垎緄勫瓧孌碉箰鍗充富閸靛瓧孌?br>as
begin
declare @max integer,@id varchar(30) ,@sql varchar(7999) ,@type integer
select @sql = 'declare cur_rows cursor for select '+@f_key+' ,count(*) from ' +@t_name +' group by ' +@f_key +' having count(*) > 1'
exec(@sql)
open cur_rows
fetch cur_rows into @id,@max
while @@fetch_status=0
begin
select @max = @max -1
set rowcount @max
select @type = xtype from syscolumns where id=object_id(@t_name) and name=@f_key
if @type=56
select @sql = 'delete from '+@t_name+' where ' + @f_key+' = '+ @id
if @type=167
select @sql = 'delete from '+@t_name+' where ' + @f_key+' = '+''''+ @id +''''
exec(@sql)
fetch cur_rows into @id,@max
end
close cur_rows
deallocate cur_rows
set rowcount 0
end

select * from systypes
select * from syscolumns where id = object_id('a_dist')



SQL import& export command

EXEC master..xp_cmdshell 'bcp SettleDB.dbo.shanghu out c:\temp1.xls -c -q -S"GNETDATA/GNETDATA" -U"sa" -P""'

/*********** 瀵煎叆Excel
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\test.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions

/*鍔ㄦ佹枃浠跺悕
declare @fn varchar(20),@s varchar(1000)
set @fn = 'c:\test.xls'
set @s ='''Microsoft.Jet.OLEDB.4.0'',
''Data Source="'+@fn+'";User ID=Admin;Password=;Extended properties=Excel 5.0'''
set @s = 'SELECT * FROM OpenDataSource ('+@s+')...sheet1$'
exec(@s)
*/

SELECT cast(cast(縐戠洰緙栧彿 as numeric(10,2)) as nvarchar(255))+'銆' 杞崲鍚庣殑鍒悕
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\test.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions

/********************** EXCEL瀵煎埌榪滅▼SQL
insert OPENDATASOURCE(
'SQLOLEDB',
'Data Source=榪滅▼ip;User ID=sa;Password=瀵嗙爜'
).搴撳悕.dbo.琛ㄥ悕 (鍒楀悕1,鍒楀悕2)
SELECT 鍒楀悕1,鍒楀悕2
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\test.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions

/** 瀵煎叆鏂囨湰鏂囦歡
EXEC master..xp_cmdshell 'bcp dbname..tablename in c:\DT.txt -c -Sservername -Usa -Ppassword'

/** 瀵煎嚭鏂囨湰鏂囦歡
EXEC master..xp_cmdshell 'bcp dbname..tablename out c:\DT.txt -c -Sservername -Usa -Ppassword'
鎴?
EXEC master..xp_cmdshell 'bcp "Select * from dbname..tablename" queryout c:\DT.txt -c -Sservername -Usa -Ppassword'

瀵煎嚭鍒癟XT鏂囨湰錛岀敤閫楀彿鍒嗗紑
exec master..xp_cmdshell 'bcp "搴撳悕..琛ㄥ悕" out "d:\tt.txt" -c -t ,-U sa -P password'

BULK INSERT 搴撳悕..琛ㄥ悕
FROM 'c:\test.txt'
WITH (
FIELDTERMINATOR = ';',
ROWTERMINATOR = '\n'
)

--/* dBase IV鏂囦歡
select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'dBase IV;HDR=NO;IMEX=2;DATABASE=C:\','select * from [瀹㈡埛璧勬枡4.dbf]')
--*/

--/* dBase III鏂囦歡
select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'dBase III;HDR=NO;IMEX=2;DATABASE=C:\','select * from [瀹㈡埛璧勬枡3.dbf]')
--*/

--/* FoxPro 鏁版嵁搴?
select * from openrowset('MSDASQL',
'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:\',
'select * from [aa.DBF]')
--*/

/**************瀵煎叆DBF鏂囦歡****************/
select * from openrowset('MSDASQL',
'Driver=Microsoft Visual FoxPro Driver;
SourceDB=e:\VFP98\data;
SourceType=DBF',
'select * from customer where country != "USA" order by country')
go
/***************** 瀵煎嚭鍒癉BF ***************/
濡傛灉瑕佸鍑烘暟鎹埌宸茬粡鐢熸垚緇撴瀯(鍗崇幇瀛樼殑)FOXPRO琛ㄤ腑,鍙互鐩存帴鐢ㄤ笅闈㈢殑SQL璇彞

insert into openrowset('MSDASQL',
'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:\',
'select * from [aa.DBF]')
select * from 琛?

璇存槑:
SourceDB=c:\ 鎸囧畾foxpro琛ㄦ墍鍦ㄧ殑鏂囦歡澶?
aa.DBF 鎸囧畾foxpro琛ㄧ殑鏂囦歡鍚?



/*************瀵煎嚭鍒癆ccess********************/
insert into openrowset('Microsoft.Jet.OLEDB.4.0',
'x:\A.mdb';'admin';'',A琛? select * from 鏁版嵁搴撳悕..B琛?

/*************瀵煎叆Access********************/
insert into B琛?selet * from openrowset('Microsoft.Jet.OLEDB.4.0',
'x:\A.mdb';'admin';'',A琛?

鏂囦歡鍚嶄負鍙傛暟
declare @fname varchar(20)
set @fname = 'd:\test.mdb'
exec('SELECT a.* FROM opendatasource(''Microsoft.Jet.OLEDB.4.0'',
'''+@fname+''';''admin'';'''', topics) as a ')

SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="f:\northwind.mdb";Jet OLEDB:Database Password=123;User ID=Admin;Password=;')...浜у搧

********************* 瀵煎叆 xml銆鏂囦歡

DECLARE @idoc int
DECLARE @doc varchar(1000)
--sample XML document
SET @doc ='
<root>
<Customer cid= "C1" name="Janine" city="Issaquah">
<Order oid="O1" date="1/20/1996" amount="3.5" />
<Order oid="O2" date="4/30/1997" amount="13.4">Customer was very satisfied
</Order>
</Customer>
<Customer cid="C2" name="Ursula" city="Oelde" >
<Order oid="O3" date="7/14/1999" amount="100" note="Wrap it blue
white red">
<Urgency>Important</Urgency>
Happy Customer.
</Order>
<Order oid="O4" date="1/20/1996" amount="10000"/>
</Customer>
</root>
'
-- Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc

-- Execute a SELECT statement using OPENXML rowset provider.
SELECT *
FROM OPENXML (@idoc, '/root/Customer/Order', 1)
WITH (oid char(5),
amount float,
comment ntext 'text()')
EXEC sp_xml_removedocument @idoc



???????

/**********************Excel瀵煎埌Txt****************************************/
鎯崇敤
select * into opendatasource(...) from opendatasource(...)
瀹炵幇灝嗕竴涓狤xcel鏂囦歡鍐呭瀵煎叆鍒頒竴涓枃鏈枃浠?

鍋囪Excel涓湁涓ゅ垪錛岀涓鍒椾負濮撳悕錛岀浜屽垪涓哄緢琛屽笎鍙?16浣?
涓旈摱琛屽笎鍙峰鍑哄埌鏂囨湰鏂囦歡鍚庡垎涓ら儴鍒嗭紝鍓?浣嶅拰鍚?浣嶅垎寮銆?

閭瑰仴錛?
濡傛灉瑕佺敤浣犱笂闈㈢殑璇彞鎻掑叆鐨勮瘽,鏂囨湰鏂囦歡蹇呴』瀛樺湪,鑰屼笖鏈変竴琛?濮撳悕,閾惰璐﹀彿1,閾惰璐﹀彿2
鐒跺悗灝卞彲浠ョ敤涓嬮潰鐨勮鍙ヨ繘琛屾彃鍏?
娉ㄦ剰鏂囦歡鍚嶅拰鐩綍鏍規嵁浣犵殑瀹為檯鎯呭喌榪涜淇敼.

insert into
opendatasource('MICROSOFT.JET.OLEDB.4.0'
,'Text;HDR=Yes;DATABASE=C:\'
)...[aa#txt]
--,aa#txt)
--*/
select 濮撳悕,閾惰璐﹀彿1=left(閾惰璐﹀彿,8),閾惰璐﹀彿2=right(閾惰璐﹀彿,8)
from
opendatasource('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;IMEX=2;DATABASE=c:\a.xls'
--,Sheet1$)
)...[Sheet1$]



濡傛灉浣犳兂鐩存帴鎻掑叆騫剁敓鎴愭枃鏈枃浠?灝辮鐢╞cp

declare @sql varchar(8000),@tbname varchar(50)

--棣栧厛灝唀xcel琛ㄥ唴瀹瑰鍏ュ埌涓涓叏灞涓存椂琛?
select @tbname='[##temp'+cast(newid() as varchar(40))+']'
,@sql='select 濮撳悕,閾惰璐﹀彿1=left(閾惰璐﹀彿,8),閾惰璐﹀彿2=right(閾惰璐﹀彿,8)
into '+@tbname+' from
opendatasource(''MICROSOFT.JET.OLEDB.4.0''
,''Excel 5.0;HDR=YES;IMEX=2;DATABASE=c:\a.xls''
)...[Sheet1$]'
exec(@sql)

--鐒跺悗鐢╞cp浠庡叏灞涓存椂琛ㄥ鍑哄埌鏂囨湰鏂囦歡
set @sql='bcp "'+@tbname+'" out "c:\aa.txt" /S"(local)" /P"" /c'
exec master..xp_cmdshell @sql

--鍒犻櫎涓存椂琛?
exec('drop table '+@tbname)

/********************瀵兼暣涓暟鎹簱*********************************************/

鐢╞cp瀹炵幇鐨勫瓨鍌ㄨ繃紼?

/*
瀹炵幇鏁版嵁瀵煎叆/瀵煎嚭鐨勫瓨鍌ㄨ繃紼?
鏍規嵁涓嶅悓鐨勫弬鏁?鍙互瀹炵幇瀵煎叆/瀵煎嚭鏁翠釜鏁版嵁搴?鍗曚釜琛?
璋冪敤紺轟緥:
--瀵煎嚭璋冪敤紺轟緥
----瀵煎嚭鍗曚釜琛?
exec file2table 'zj','','','xzkh_sa..鍦板尯璧勬枡','c:\zj.txt',1
----瀵煎嚭鏁翠釜鏁版嵁搴?
exec file2table 'zj','','','xzkh_sa','C:\docman',1

--瀵煎叆璋冪敤紺轟緥
----瀵煎叆鍗曚釜琛?
exec file2table 'zj','','','xzkh_sa..鍦板尯璧勬枡','c:\zj.txt',0
----瀵煎叆鏁翠釜鏁版嵁搴?
exec file2table 'zj','','','xzkh_sa','C:\docman',0

*/
if exists(select 1 from sysobjects where name='File2Table' and objectproperty(id,'IsProcedure')=1)
drop procedure File2Table
go
create procedure File2Table
@servername varchar(200) --鏈嶅姟鍣ㄥ悕
,@username varchar(200) --鐢ㄦ埛鍚?濡傛灉鐢∟T楠岃瘉鏂瑰紡,鍒欎負絀?'
,@password varchar(200) --瀵嗙爜
,@tbname varchar(500) --鏁版嵁搴?dbo.琛ㄥ悕,濡傛灉涓嶆寚瀹?.dbo.琛ㄥ悕,鍒欏鍑烘暟鎹簱鐨勬墍鏈夌敤鎴瘋〃
,@filename varchar(1000) --瀵煎叆/瀵煎嚭璺緞/鏂囦歡鍚?濡傛灉@tbname鍙傛暟鎸囨槑鏄鍑烘暣涓暟鎹簱,鍒欒繖涓弬鏁版槸鏂囦歡瀛樻斁璺緞,鏂囦歡鍚嶈嚜鍔ㄧ敤琛ㄥ悕.txt
,@isout bit --1涓哄鍑?0涓哄鍏?
as
declare @sql varchar(8000)

if @tbname like '%.%.%' --濡傛灉鎸囧畾浜嗚〃鍚?鍒欑洿鎺ュ鍑哄崟涓〃
begin
set @sql='bcp '+@tbname
+case when @isout=1 then ' out ' else ' in ' end
+' "'+@filename+'" /w'
+' /S '+@servername
+case when isnull(@username,'')='' then '' else ' /U '+@username end
+' /P '+isnull(@password,'')
exec master..xp_cmdshell @sql
end
else
begin --瀵煎嚭鏁翠釜鏁版嵁搴?瀹氫箟娓告爣,鍙栧嚭鎵鏈夌殑鐢ㄦ埛琛?
declare @m_tbname varchar(250)
if right(@filename,1)<>'\' set @filename=@filename+'\'

set @m_tbname='declare #tb cursor for select name from '+@tbname+'..sysobjects where xtype=''U'''
exec(@m_tbname)
open #tb
fetch next from #tb into @m_tbname
while @@fetch_status=0
begin
set @sql='bcp '+@tbname+'..'+@m_tbname
+case when @isout=1 then ' out ' else ' in ' end
+' "'+@filename+@m_tbname+'.txt " /w'
+' /S '+@servername
+case when isnull(@username,'')='' then '' else ' /U '+@username end
+' /P '+isnull(@password,'')
exec master..xp_cmdshell @sql
fetch next from #tb into @m_tbname
end
close #tb
deallocate #tb
end
go

/************* Oracle **************/
EXEC sp_addlinkedserver 'OracleSvr',
'Oracle 7.3',
'MSDAORA',
'ORCLDB'
GO

delete from openquery(mailser,'select * from yulin')

select * from openquery(mailser,'select * from yulin')

update openquery(mailser,'select * from yulin where id=15')set disorder=555,catago=888

insert into openquery(mailser,'select disorder,catago from yulin')values(333,777)



琛ュ厖錛?

瀵逛簬鐢╞cp瀵煎嚭,鏄病鏈夊瓧孌靛悕鐨?

鐢╫penrowset瀵煎嚭,闇瑕佷簨鍏堝緩濂借〃.

鐢╫penrowset瀵煎叆,闄CCESS鍙奅XCEL澶?鍧囦笉鏀寔闈炴湰鏈烘暟鎹鍏?
鍒犻櫎


鍙跺瓙 2007-12-06 11:19 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲影视在线播放| 午夜精品视频| 欧美国产亚洲视频| 免费亚洲电影| 亚洲卡通欧美制服中文| 亚洲国产网站| 欧美另类69精品久久久久9999| 亚洲精品乱码久久久久久蜜桃麻豆 | 欧美大色视频| 亚洲精品久久久久久久久久久久| 亚洲电影免费观看高清| 欧美精品自拍偷拍动漫精品| 亚洲一级片在线观看| 亚洲影院色无极综合| 国产一区二区三区四区五区美女| 老牛嫩草一区二区三区日本| 免费一级欧美片在线播放| 夜夜嗨一区二区| 亚洲一区网站| 在线国产亚洲欧美| 亚洲美女中文字幕| 国产一区日韩欧美| 亚洲经典在线| 国产情侣一区| 最新国产成人在线观看| 国产精品爽黄69| 男人的天堂成人在线| 欧美日韩视频一区二区| 久久久亚洲精品一区二区三区| 久久三级视频| 翔田千里一区二区| 免费日韩精品中文字幕视频在线| 一区二区激情视频| 久久久久久夜| 亚洲欧美日韩国产一区| 免费观看亚洲视频大全| 性做久久久久久久免费看| 欧美成人一区二区在线| 欧美中文字幕精品| 欧美另类极品videosbest最新版本| 午夜精品在线看| 欧美久久久久久| 久久久久五月天| 国产精品久久国产精麻豆99网站| 欧美成ee人免费视频| 国产精品乱子久久久久| 最新国产拍偷乱拍精品| 狠狠网亚洲精品| 亚洲一区免费视频| 国产精品99久久99久久久二8| 欧美在线影院| 欧美一区二区福利在线| 欧美激情精品久久久六区热门| 久久精品夜色噜噜亚洲a∨| 欧美日韩一区二区三| 欧美大片网址| 亚洲第一网站| 亚洲欧美在线一区二区| 亚洲欧美三级在线| 欧美色图天堂网| 亚洲毛片av在线| 亚洲精品一区二区三区婷婷月| 久久久久国产精品厨房| 久久精选视频| 狠狠爱成人网| 久久精品视频在线观看| 久久久久久久久久久久久9999| 国产麻豆综合| 欧美一级淫片播放口| 欧美在线高清视频| 国产一区二区三区不卡在线观看| 亚洲一区精品在线| 久久精品1区| 黄色影院成人| 久久综合伊人| 亚洲电影天堂av| 99视频一区二区三区| 欧美日韩视频一区二区| 99这里只有精品| 欧美一级专区| 韩国欧美一区| 免费高清在线一区| 亚洲精品视频在线观看网站| 亚洲毛片一区| 国产精品久久久久久久免费软件| 亚洲午夜精品一区二区三区他趣| 亚洲欧美国产va在线影院| 国产欧美一区二区精品性| 久久精品国产亚洲一区二区| 美女91精品| 一区二区久久久久久| 国产精品成人国产乱一区| 午夜免费久久久久| 欧美国产视频日韩| 亚洲视频图片小说| 国产一区二区三区久久悠悠色av| 久久综合九色综合欧美就去吻| 亚洲精品欧美激情| 久久gogo国模裸体人体| 亚洲第一毛片| 国产精品igao视频网网址不卡日韩| 亚洲制服av| 亚洲国产精品国自产拍av秋霞| 亚洲一区二区免费看| 狠狠色噜噜狠狠色综合久| 欧美高清在线视频观看不卡| 亚洲一区二区三区在线看| 欧美.com| 欧美一级黄色网| 亚洲精品九九| 国产综合第一页| 欧美视频二区| 老色鬼久久亚洲一区二区| 亚洲图片你懂的| 亚洲国产欧美在线人成| 午夜精品福利在线| 99国产精品久久久久老师| 国产综合色在线| 国产精品高清网站| 欧美高清一区二区| 久久久久国产精品人| 一区二区三区精品视频在线观看| 久久国产精品99精品国产| 一本色道久久综合狠狠躁篇怎么玩 | 欧美日韩免费一区二区三区| 性欧美大战久久久久久久免费观看| 亚洲欧洲一区二区三区在线观看 | 一区二区三区国产| 亚洲电影av在线| 国产日韩欧美不卡| 欧美日韩综合视频网址| 美国十次了思思久久精品导航| 欧美一区二区三区四区在线| 亚洲免费观看在线观看| 亚洲第一精品久久忘忧草社区| 久久久亚洲欧洲日产国码αv| 亚洲欧美激情一区二区| 一区二区三区精密机械公司 | 国产女同一区二区| 欧美日韩综合久久| 欧美日韩国产二区| 欧美激情精品久久久久久| 狼人天天伊人久久| 久久综合给合久久狠狠色| 欧美一区二区三区男人的天堂| 亚洲午夜日本在线观看| 中日韩美女免费视频网址在线观看 | 夜夜精品视频| 99热这里只有精品8| 亚洲老板91色精品久久| 亚洲全黄一级网站| 亚洲精品欧洲| 一区二区免费在线观看| 一区二区三区免费网站| 亚洲一区二区久久| 亚洲男人av电影| 欧美一区二区三区四区视频| 欧美中文字幕视频在线观看| 久久gogo国模裸体人体| 久久精品国产亚洲a| 久久久777| 欧美成人综合一区| 亚洲精品国精品久久99热| 99精品国产在热久久| 亚洲午夜视频在线观看| 亚洲男人的天堂在线观看 | 欧美好吊妞视频| 亚洲黄色成人| 亚洲精品国产精品久久清纯直播| 亚洲日本电影| 亚洲午夜女主播在线直播| 欧美在线视频不卡| 欧美99久久| 欧美亚洲成人精品| 韩国福利一区| 9人人澡人人爽人人精品| 午夜精品久久久| 另类亚洲自拍| 99精品欧美一区二区蜜桃免费| 午夜精品福利一区二区三区av| 久久人人97超碰精品888| 欧美日韩国产探花| 国产真实久久| 一区二区三区产品免费精品久久75| 午夜精品在线观看| 亚洲电影免费观看高清完整版在线观看| 亚洲国产精品一区| 亚洲欧美另类中文字幕| 免费看av成人| 国产精品日本欧美一区二区三区| 狠狠色丁香久久综合频道| 99国产精品久久久| 久久综合99re88久久爱| 亚洲日本成人网| 欧美专区在线| 国产精品久久久久久久久久久久 | 国产精品日韩精品欧美在线| 在线观看亚洲a| 欧美一级大片在线免费观看| 欧美激情片在线观看|