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

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ÎļþµÄ·½·¨:
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
/*--Êý¾Ýµ¼³öEXCEL
µ¼³ö±íÖеÄÊý¾Ýµ½Excel,°üº¬×Ö¶ÎÃû,ÎļþΪÕæÕýµÄExcelÎļþ
,Èç¹ûÎļþ²»´æÔÚ,½«×Ô¶¯´´½¨Îļþ
,Èç¹û±í²»´æÔÚ,½«×Ô¶¯´´½¨±í
»ùÓÚͨÓÃÐÔ¿¼ÂÇ,½öÖ§³Öµ¼³ö±ê×¼Êý¾ÝÀàÐÍ
--×Þ½¨ 2003.10(ÒýÓÃÇë±£Áô´ËÐÅÏ¢)--*/
/*--µ÷ÓÃʾÀý
p_exporttb @tbname='µØÇø×ÊÁÏ',@path='c:\',@fname='aa.xls'
--*/
create proc p_exporttb
@tbname sysname,     --Òªµ¼³öµÄ±íÃû
@path nvarchar(1000),    --Îļþ´æ·ÅĿ¼
@fname nvarchar(250)=''   --ÎļþÃû,ĬÈÏΪ±íÃû
as
declare @err int,@src nvarchar(255),@desc nvarchar


Ïà¹ØÎĵµ£º

¶¯Ì¬SQL

Sample1:
/* Variable Declaration */
DECLARE @EmpID AS SMALLINT
DECLARE @SQLQuery AS NVARCHAR(500)
/* Build and Execute a Transact-SQL String with a single parameter value Using EXECUTE Command */
SET @EmpID = 1001
SET @SQLQuery = 'SELECT * from tblEmployees WHERE EmployeeID = ' + CAST(@EmpID A ......

ÕÒµ½ÒýÆð´ÅÅÌÅÅÐòµÄSQL

ÏÂÃæµÄÕâЩ½Å±¾¶¼¿ÉÒÔÕÒµ½ÒýÆð´ÅÅÌÅÅÐòµÄSQL¡£ 
SELECT /*+ rule */ DISTINCT a.SID, a.process, a.serial#,
TO_CHAR (a.logon_time, 'YYYYMMDD HH24:MI:SS') LOGON, a.osuser,TABLESPACE, b.sql_text
from v$session a, v$sql b, v$sort_usage c
WHERE a.sql_address = b.address AND a.saddr = c.session_addr; ......

¾¡Á¿²»ÒªÆ´´ÕSqlÓï¾ä,ÓòÎÊýÀ´·À×¢Èë

    Èç¹ûÊÇÀàËÆ"select   *   from   user   where   uid="+uid +"  and   pwd="+pwd ºÜÈÝÒ׳öÎÊÌâ
    ʹÓà   SQLParamenter      
    °ÑÄãµÄSQLÓï¾äд³É   ÀàËÆ´æ´¢¹ý³Ì   ......

sqlÄ£ºý²éѯ

SELECT * from user WHERE name LIKE '%Èý%';
½«»á°ÑnameΪ“ÕÅÈý”£¬“Èý½Å蔣¬“ÌÆÈý²Ø”µÈµÈÓГÈý”µÄÈ«ÕÒ³öÀ´£»
ÔÚ½øÐÐÊý¾Ý¿â²éѯʱ£¬ÓÐÍêÕû²éѯºÍÄ£ºý²éѯ֮·Ö¡£
Ò»°ãÄ£ºýÓï¾äÈçÏ£º
SELECT ×ֶΠfrom ±í WHERE ij×ֶΠLike Ìõ¼þ
ÆäÖйØÓÚÌõ¼þ£¬SQLÌṩÁËËÄÖÖÆ¥ÅäÄ£Ê ......

MyEclipseÁ¬½ÓSQL Server 2000´íÎóÅųý

ÔÚÁ¬½ÓSQL Server 2000Êý¾Ý¿âʱ£¬ÏµÍ³ÌáʾÈçÏ´íÎó£º
ÔÚÍøÉÏÑ°ÕÒµ½´¦Àí·½·¨£º
(°ÑSQL server updateµ½sp4)
1¡¢ÔÚ²éѯ·ÖÎöÆ÷ÖÐÊäÈë select @@version ²¢Ö´ÐÐ
SQL Server 2000 °æ±¾ºÍ¼¶±ð
@@VERSION
²úÆ·¼¶±ð
 
SQL Server 2000 ԭʼ°æ±¾
8.00.194
RTM
 
Database Components SP1
8.00.384
SP1 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ