Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLµ¼³öµ½ExcelµÄÓï¾ä

sqlµ¼³öµ½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ÎļþµÄ¹¤×÷±íÃû,Ò»°ãÒª¼ÓÉÏ$²ÅÄÜÕý³£Ê¹ÓÃ.
ÏÂÃæÊǵ¼³öÕæÕýExcelÎļþµÄ·½·¨:
/*--Êý¾Ýµ¼³öEXCEL
µ¼³ö±íÖеÄÊý¾Ýµ½Excel,°üº¬×Ö¶ÎÃû,ÎļþΪÕæÕýµÄExcelÎļþ
,Èç¹ûÎļþ²»´æÔÚ,½«×Ô¶¯´´½¨Îļþ
,Èç¹û±í²»´æÔÚ,½«×Ô¶¯´´½¨±í
»ùÓÚͨÓÃÐÔ¿¼ÂÇ,½öÖ§³Öµ¼³ö±ê×¼Êý¾ÝÀàÐÍ
---*/
/*--µ÷ÓÃʾÀý
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,     --Òªµ¼³öµÄ±íÃû,×¢ÒâÖ»ÄÜÊDZíÃû/ÊÓͼÃû
@path nvarchar(1000),    --Îļþ´æ·ÅĿ¼
@fname nvarchar(250)=''   --ÎļþÃû,ĬÈÏΪ±íÃû
as
declare @err int,@src nvarchar(255),@desc nvarchar(255),@out i


Ïà¹ØÎĵµ£º

SQL SERVER 2005 ͬ²½¸´ÖƼ¼Êõ

SQL SERVER 2005 ͬ²½¸´ÖƼ¼Êõ
ÒÔÏÂʵÏÖ¸´ÖƲ½Ö裨ÒÔ¿ìÕÕ¸´ÖÆΪÀý£©
ÔËÐÐƽ̨SQL SERVER 2005
Ò»¡¢×¼±¸¹¤×÷£º
1£®½¨Á¢Ò»¸ö WINDOWS Óû§£¬ÉèÖÃΪ¹ÜÀíԱȨÏÞ£¬²¢ÉèÖÃÃÜÂ룬×÷Ϊ·¢²¼¿ìÕÕÎļþµÄÓÐЧ·ÃÎÊÓû§¡£
2£®ÔÚSQL SERVERÏÂʵÏÖ·¢²¼·þÎñÆ÷ºÍ¶©ÔÄ·þÎñÆ÷µÄͨÐÅÕý³££¨¼´¿ÉÒÔ»¥·Ã£©¡£´ò¿ª1433¶Ë¿Ú£¬ÔÚ·À»ðǽÖÐÉèÌØÀ ......

sql´æ´¢¹ý³Ì¶ÁÈ¡ÐÅÏ¢ÖÐÎÊÌâ

sql="select * from (select top 4 ID,SmallPic,NewsNameSi,EndDate,ContentSi,SortID from achi_news where ProductProperty=1 and IsOk=1 and HomeForcePage=1 and HomeEndTime>getDate() and isdate(HomeEndTime)=1 order by HomeorderNum asc  )a union all select * from (select top 4 ID,SmallPic,NewsNameS ......

SQL Server 2005ºÍSQL Server 2000Êý¾ÝµÄÏ໥µ¼Èë

¡¡×Ô´ÓSQL Server 2005ÍƳöºó£¬ÒòΪÓÐÁ˸üºÃµÄÐÔÄÜ£¬ËùÒÔÓкܶàÓëSQL Server 2000Ïà¹ØµÄÓ¦ÓóÌÐòÐèÒªÉý¼¶µ½Õâ¸ö°æ±¾¡£µ«ÈçºÎ²ÅÄÜÒÔ×î¿ì×î·½±ãµÄ·½Ê½°ÑÆäÖеıí½á¹¹¼°¶ÔÓ¦µÄÊý¾ÝºÍÊý¾ÝµÄÆäËüµÄ¸ñʽµ¼Èëµ½SQL Server 2005ÄØ£¿SQL Server 2005µÄÊý¾ÝÓÖÈçºÎµ¼Èëµ½SQL Server 2000ÉÏ£¿ÎÒÃÇ·Ö±ðÀ´¿´ÏÂÃæʵÏֵķ½Ê½£º
¡¡¡¡1) SQL ......

SQLÉú³ÉÁ÷Ë®ºÅ

¾­¹ýÁ˼¸´ÎµÄ²âÊÔÖÕÓڳɹ¦ÁË
declare @Year Int,
        @Month int,
        @Day int,
        @Temp_No varchar(12),
        @NeedNo varchar(4),
   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ