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

SQLÓï¾äµ¼Èëµ¼³ö´óÈ«


SQLÓï¾äµ¼Èëµ¼³ö´óÈ«
/*******  µ¼³öµ½excel
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

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
/** µ¼ÈëÎı¾Îļþ
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¡¯
µ¼³öµ½TXTÎı¾£¬ÓöººÅ·Ö¿ª
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 * fr


Ïà¹ØÎĵµ£º

SQL SERVERµÄROWCOUNT¹Ø¼ü×Ö

 
ÒòΪÑöÍûORACLE£¬ËùÒÔÒ»Ö±¶¼ÒÔΪSQL SERVERºÜ±¿¡£
¾Ý´«SQL 2005ÓÐÁËRowIDµÄ¶«Î÷£¬¿ÉÒÔ½â¾öTOPÅÅÐòµÄÎÊÌâ¡£¿Éϧ»¹Ã»Óлú»áÌåÑé¡£ÔÚSQL 2000ÖÐд´æ´¢¹ý³Ì£¬×Ü»áÓöµ½ÐèÒªTOPµÄµØ·½£¬¶øÒ»µ©Óöµ½TOP£¬ÒòΪû°ì·¨°ÑTOPºóÃæµÄÊý×Ö×÷Ϊ±äÁ¿Ð´µ½Ô¤±àÒëµÄÓï¾äÖÐÈ¥£¬ËùÒÔÖ»Äܹ»Ê¹Óù¹Ôì SQL£¬Ê¹ÓÃExecÀ´Ö´ÐС£²»ËµÐ§ÂʵÄÎÊÌ⣠......

½²½âSQL ServerÖÐÈÝÒ×»ìÏýµÄÊý¾ÝÀàÐÍ


½²½âSQL ServerÖÐÈÝÒ×»ìÏýµÄÊý¾ÝÀàÐÍ
(1)char¡¢varchar¡¢textºÍnchar¡¢nvarchar¡¢ntext 
¡¡¡¡charºÍvarcharµÄ³¤¶È¶¼ÔÚ1µ½8000Ö®¼ä£¬ËüÃǵÄÇø±ðÔÚÓÚcharÊǶ¨³¤×Ö·ûÊý¾Ý£¬¶øvarcharÊDZ䳤×Ö·ûÊý¾Ý¡£Ëùν¶¨³¤¾ÍÊdz¤¶È¹Ì¶¨µÄ£¬µ±ÊäÈëµÄÊý¾Ý³¤¶ÈûÓдﵽָ¶¨µÄ³¤¶Èʱ½«×Ô¶¯ÒÔÓ¢ÎÄ¿Õ¸ñÔÚÆäºóÃæÌî³ä£¬Ê¹³¤¶È´ïµ½ÏàÓ¦ ......

SQL ServerÈÕÆÚ´¦ÀídatetimeºÍdateÖ®¼äµÄÏ໥ת»»

 
ÈÕÆÚÀàÐ͸ÅÊö
SQL ServerÖеÄÈÕÆÚÀàÐÍ°üÀ¨datetimeºÍsmalldatetime£¬½öÄÜ´¦Àí¿ÉÒÔʶ±ðΪ1753Äê¡«9999Äê¼äµÄÈÕÆÚµÄÖµ£¬Ã»Óе¥¶ÀµÄÈÕÆÚÐÍ»òʱ¼äÐÍ¡£
1£®datetime
datetimeÀàÐÍ´¦Àí´Ó1753Äê1ÔÂ1ÈÕ¡«9999Äê12ÔÂ31ÈÕµÄÈÕÆÚºÍʱ¼äÊý¾Ý£¬¾«È·¶ÈΪ°Ù·ÖÖ®ÈýÃë¡£
¼´£º¶ÔÓÚ0.000¡«0.001¡¢0.009µÄÈÕÆÚÖµ£¬µ÷ÕûΪ0.000£»¶ÔÓÚ ......

Oracle PL/SQLÈëÃÅÖ®¿®Êö

 Ò»¡¢PL/SQL³öÏÖµÄÄ¿µÄ
¡¡¡¡½á¹¹»¯²éѯÓïÑÔ(Structured Query
Language£¬¼ò³ÆSQL)ÊÇÓÃÀ´·ÃÎʹØϵÐÍÊý¾Ý¿âÒ»ÖÖͨÓÃÓïÑÔ£¬ËüÊôÓÚµÚËÄ´úÓïÑÔ£¨4GL£©£¬ÆäÖ´ÐÐÌصãÊǷǹý³Ì»¯£¬¼´²»ÓÃÖ¸Ã÷Ö´ÐеľßÌå·½·¨ºÍ;
¾¶£¬¶øÊǼòµ¥µÄµ÷ÓÃÏàÓ¦Óï¾äÀ´Ö±½ÓÈ¡µÃ½á¹û¼´¿É¡£ÏÔÈ»£¬ÕâÖÖ²»¹Ø×¢ÈκÎʵÏÖϸ½ÚµÄÓïÑÔ¶ÔÓÚ¿ª·¢ÕßÀ´ËµÓÐ׿«´óµÄ ......

SQLº¯ÊýÖ®ËÄÉáÎåÈë

SQLº¯ÊýÖ®ËÄÉáÎåÈ루ת×Ôhttp://ln1058.javaeye.com/blog/191502£©
ÎÊÌâ1£º
SELECT CAST('123.456' as decimal) ½«»áµÃµ½ 123£¨Ð¡ÊýµãºóÃæµÄ½«»á±»Ê¡ÂÔµô£©¡£
Èç¹ûÏ£ÍûµÃµ½Ð¡ÊýµãºóÃæµÄÁ½Î»¡£
ÔòÐèÒª°ÑÉÏÃæµÄ¸ÄΪ
SELECT CAST('123.456' as decimal(38, 2)) ===>123.46
×Ô¶¯ËÄÉáÎåÈëÁË£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ