SQL ServerÓëExcelÊý¾Ý»¥µ¼
SQL ServerÓëExcelÊý¾Ý»¥µ¼
´ÓSQL ServerÖе¼Èë/µ¼³ö Excel µÄ»ù±¾·½·¨
/*=================== µ¼Èë/µ¼³ö Excel µÄ»ù±¾·½·¨ ===================*/
´ÓExcelÎļþÖÐ,µ¼ÈëÊý¾Ýµ½SQLÊý¾Ý¿âÖÐ,ºÜ¼òµ¥,Ö±½ÓÓÃÏÂÃæµÄÓï¾ä:
/*========================================================*/
--Èç¹û½ÓÊÜÊý¾Ýµ¼ÈëµÄ±íÒѾ´æÔÚ
insert into ±í select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=c:test.xls',sheet1$)
--Èç¹ûµ¼ÈëÊý¾Ý²¢Éú³É±í
select * into ±í from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=c:test.xls',sheet1$)
/*========================================================*/
--Èç¹û´ÓSQLÊý¾Ý¿âÖÐ,µ¼³öÊý¾Ýµ½Excel,Èç¹ûExcelÎļþÒѾ´æÔÚ,¶øÇÒÒѾ°´ÕÕÒª½ÓÊÕµÄÊý¾Ý´´½¨ºÃ±íÍ·,¾Í¿ÉÒÔ¼òµ¥µÄÓÃ:
insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=c:test.xls',sheet1$)
select * from ±í
--Èç¹ûExcelÎļþ²»´æÔÚ,Ò²¿ÉÒÔÓÃBCPÀ´µ¼³ÉÀàExcelµÄÎļþ,×¢Òâ´óСд:
--µ¼³ö±íµÄÇé¿ö
EXEC master..xp_cmdshell 'bcp Êý¾Ý¿âÃû.dbo.±íÃû out "c:test.xls" /c -/S"·þÎñÆ÷Ãû" /U"Óû§Ãû" -P"ÃÜÂë"'
--µ¼³ö²éѯµÄÇé¿ö
EXEC master..xp_cmdshell 'bcp "SELECT au_fname, au_lname from pubs..authors ORDER BY au_lname" queryout "c:test.xls" /c -/S"·þÎñÆ÷Ãû" /U"Óû§Ãû" -P"ÃÜÂë"'
/*--˵Ã÷:
c:test.xls Ϊµ¼Èë/µ¼³öµÄExcelÎļþÃû.
sheet1$ ΪExcelÎļþµÄ¹¤×÷±íÃû,Ò»°ãÒª¼ÓÉÏ$²ÅÄÜÕý³£Ê¹ÓÃ.
--*/
--ÉÏÃæÒѾ˵¹ý,ÓÃBCPµ¼³öµÄÊÇÀàExcelÎļþ,ÆäʵÖÊΪÎı¾Îļþ,
--Òªµ¼³öÕæÕýµÄExcelÎļþ.¾ÍÓÃÏÂÃæµÄ·½·¨
/*--Êý¾Ýµ¼³öEXCEL
µ¼³ö±íÖеÄÊý¾Ýµ½Excel,°üº¬×Ö¶ÎÃû,ÎļþÎªÕæÕýµÄExcelÎļþ
,Èç¹ûÎļþ²»´æÔÚ,½«×Ô¶¯´´½¨Îļþ
,Èç¹û±í²»´æÔÚ,½«×Ô¶¯´´½¨±í
»ùÓÚͨÓÃÐÔ¿¼ÂÇ,½öÖ§³Öµ¼³ö±ê×¼Êý¾ÝÀàÐÍ
--×Þ½¨ 2003.10--*/
/*--µ÷ÓÃʾÀý
p_exporttb @tbname='µØÇø×ÊÁÏ',@path='c:',@fname='aa.xls'
--*/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_exporttb]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_exporttb]
GO
create proc p_exporttb
@tbname sysname, --Òªµ¼³öµÄ±íÃû
@path nvarchar(1000), --Îļþ´æ·ÅĿ¼
@f
Ïà¹ØÎĵµ£º
ÕªÒª£º±¾ÎĽéÉÜÁËÔÚ¿Í»§»úÉÏ´¦Àí Microsoft sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) ²éѯµÄ·½Ê½£¬¸÷ÖÖ¿Í»§»úÓë sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) µÄ½»»¥·½Ê½£¬ÒÔ¼° sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) ÔÚ´¦Àí¿Í»§»ú³ÌÐòµÄÇëÇóʱÐèÒªÍê³ÉµÄ¹¤×÷¡£
¼ò½é
¡¡¡¡Microsoft(R) sql server(WINDOWSƽ̨ÉÏÇ¿ ......
1.Oracleɾ³ýÖØ¸´¼Ç¼.
ɾ³ý±íÖжàÓàµÄÖØ¸´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´Åжϣ¬Ö»ÁôÓÐrowid×îСµÄ¼Ç¼.
delete from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
and rowid not i ......
ORACLE SQLÐÔÄÜÓÅ»¯ÏµÁÐ
1. ·ÃÎÊTableµÄ·½Ê½
ORACLE ²ÉÓÃÁ½ÖÖ·ÃÎʱíÖмǼµÄ·½Ê½:
a. È«±íɨÃè
È«±íɨÃè¾ÍÊÇ˳ÐòµØ·ÃÎʱíÖÐÿÌõ¼Ç¼. ORACLE²ÉÓÃÒ»´Î¶ÁÈë¶à¸öÊý¾Ý¿é(database block)µÄ·½Ê½ÓÅ»¯È«±íɨÃè.
b. ͨ¹ýROWID·ÃÎʱí
Äã¿ÉÒÔ²ÉÓûùÓÚROWIDµÄ·ÃÎÊ·½Ê½Çé¿ö,Ìá¸ß·ÃÎʱíµÄЧÂÊ, , ROWID°üº¬Á˱íÖмǼµ ......
1¡£Èç¹û×°sql serverÖÐδ³öÏÖÒì³£µÄ»°£¬ÇÒһЩ×ÔÑ¡²ÎÊý£¬ÕË»§£¬ÃÜÂëµÈûÓдíÎóµÄ»°¡£Ò»µ©³öÏÖÖîÈçsocket½¨Á¢²»Æð£¬Á¬½Ó²»ÉϵÈÎÊÌâ¡£×îÓÐЧµÄ½â¾ö·½·¨ÊÇ´ò²¹¶¡£¬ÆäÖÐsp4£ºhttp://www.microsoft.com/downloads/details.aspx?DisplayLang=zh-cn&FamilyID=8e2dfc8d-c20e-4446-99a9-b7f0213f8bc5£¬sp3a£ºhttp://www.microsof ......
SqlCommand com = new SqlCommand("select * from myuser where username=@UserName and password=@Pwd", con);
com.Parameters.Add(new SqlParameter("@UserN ......