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ÖÐÈÝÒ×»ìÏýµÄÊý¾ÝÀàÐÍ
(1)char¡¢varchar¡¢textºÍnchar¡¢nvarchar¡¢ntext
¡¡¡¡charºÍvarcharµÄ³¤¶È¶¼ÔÚ1µ½8000Ö®¼ä£¬ËüÃǵÄÇø±ðÔÚÓÚcharÊǶ¨³¤×Ö·ûÊý¾Ý£¬¶øvarcharÊDZ䳤×Ö·ûÊý¾Ý¡£Ëùν¶¨³¤¾ÍÊdz¤¶È¹Ì¶¨µÄ£¬µ±ÊäÈëµÄÊý¾Ý³¤¶ÈûÓдﵽָ¶¨µÄ³¤¶Èʱ½«×Ô¶¯ÒÔÓ¢ÎÄ¿Õ¸ñÔÚÆäºóÃæÌî³ä£¬Ê¹³¤¶È´ïµ½ÏàÓ¦ ......
(1)¹ØÓÚ´æ´¢¹ý³Ì·µ»ØÖµÎÊÌ⣨output,ruturn£©
output´æ´¢¹ý³Ì£º
alter proc usp_update
@count int output
as
set @count=(select count(*) from stu)
return´æ´¢¹ý³Ì£º
alter proc usp_update
as
declare @count int
set @count=(select count(*) from stu)
r ......
ʮһ¡¢ÒÔÉϺ¯ÊýµÄ²¿·ÖʵÀý
1:replace º¯Êý
µÚÒ»¸ö²ÎÊýÄãµÄ×Ö·û´®£¬µÚ¶þ¸ö²ÎÊýÄãÏëÌæ»»µÄ²¿·Ö£¬µÚÈý¸ö²ÎÊýÄãÒªÌæ»»³Éʲô
select replace('lihan','a','b')
& ......
˵µ½Èí½âÎö£¨soft prase£©ºÍÓ²½âÎö£¨hard prase£©£¬¾Í²»Äܲ»ËµÒ»ÏÂOracle¶ÔsqlµÄ´¦Àí¹ý³Ì¡£µ±Äã·¢³öÒ»ÌõsqlÓï¾ä½»¸¶Oracle£¬ÔÚÖ´ÐкͻñÈ¡½á¹ûÇ°£¬Oracle¶Ô´Ësql½«½øÐм¸¸ö²½ÖèµÄ´¦Àí¹ý³Ì£º
1¡¢Óï·¨¼ì²é£¨syntax check£©
¼ì²é´Ë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
×Ô¶¯ËÄÉáÎåÈëÁË£ ......