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
/*¶¯Ì¬ÎļþÃû
declare @fn varchar(20),@s varchar(1000)
set @fn = 'c:\test.xls'
set @s ='''Microsoft.Jet.OLEDB.4.0'',
''Data Source="'+@fn+'";User ID=Admin;Password=;Extended properties=Excel 5.0'''
set @s = 'SELECT * from OpenDataSource ('+@s+')...sheet1$'
exec(@s)
*/
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
/********************** EXCELµ¼µ½Ô¶³ÌSQL
insert OPENDATASOURCE(
'SQLOLEDB',
'Data Source=Ô¶³Ìip;User ID=sa;Password=ÃÜÂë'
).¿âÃû.dbo.±íÃû (ÁÐÃû1,ÁÐÃû2)
SELECT ÁÐÃû1,ÁÐÃû2
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 [¿Í»§×Ê
Ïà¹ØÎĵµ£º
1.sp_helpsort
SELECT SERVERPROPERTY ('Collation')
²é¿´ÄãµÄÅÅÐò¹æÔò.
²»¹ýÄãµÄÕâ¸öÓ¦¸ÃºÍ×Ö·û¼¯ÓйØ.
2.¸ü¸Ä·þÎñÆ÷ÅÅÐò¹æÔò
¸ü¸Ä SQL Server 2005 ʵÀýµÄĬÈÏÅÅÐò¹æÔòµÄ²Ù×÷¿ÉÄÜ»á±È½Ï¸´ÔÓ£¬°üÀ¨ÒÔϲ½Ö裺
È·±£¾ßÓÐÖØд´½¨Óû§Êý¾Ý¿â¼°ÕâЩÊý¾Ý¿âÖеÄËùÓжÔÏóËùÐèµÄÈ«²¿ÐÅÏ¢»ò½Å±¾¡£
ʹÓù¤¾ß£¨ÀýÈç´óÈÝÁ ......
¹Ì¶¨³¤¶È(char)Óë¿É±ä³¤¶È(varchar)×Ö·ûÊý¾ÝÀàÐÍ
char[(n)]
³¤¶ÈΪn¸ö×ֽڵĹ̶¨³¤¶ÈÇÒ·ÇUnicodeµÄ×Ö·ûÊý¾Ý¡£n±ØÐëÊÇÒ»¸ö½éÓÚ1ºÍ8,000Ö®¼äµÄÊýÖµ¡£´æ´¢´óСΪn¸ö×Ö½Ú¡£charÔÚSQL-92ÖеÄͬÒå´ÊΪcharacter¡£
varchar[(n)]
³¤¶ÈΪn¸ö×ֽڵĿɱ䳤¶ÈÇÒ·ÇUnicodeµÄ×Ö·ûÊý¾Ý¡£n±ØÐëÊÇÒ»¸ö½éÓÚ1ºÍ8,000Ö®¼äµÄÊýÖµ¡£´æ´¢´óСΪ ......
ͨ¹ýv$sqlarea,v$sql²éѯ×îÕ¼ÓÃ×ÊÔ´µÄ²éѯ ÊÕ²Ø
ÒýÓÃ:http://blog.chinaunix.net/u/3866/showart_396335.html
-----------------------
v$sqlarea,v$sql
-----------------------
´ÓV$SQLAREAÖвéѯ×îÕ¼ÓÃ×ÊÔ´µÄ²éѯ
select b.username username,a.disk_reads reads,
a.executions exec,a ......
Ò»¡¢Êʺ϶ÁÕ߶ÔÏó£ºÊý¾Ý¿â¿ª·¢³ÌÐòÔ±£¬Êý¾Ý¿âµÄÊý¾ÝÁ¿ºÜ¶à£¬Éæ¼°µ½¶ÔSP£¨´æ´¢¹ý³Ì£©µÄÓÅ»¯µÄÏîÄ¿¿ª·¢ÈËÔ±£¬¶ÔÊý¾Ý¿âÓÐŨºñÐËȤµÄÈË¡£ ¡¡
¶þ¡¢½éÉÜ£ºÔÚÊý¾Ý¿âµÄ¿ª·¢¹ý³ÌÖУ¬¾³£»áÓöµ½¸´ÔÓµÄÒµÎñÂß¼ºÍ¶ÔÊý¾Ý¿âµÄ²Ù×÷£¬Õâ¸öʱºò¾Í»áÓÃSPÀ´·â×°Êý¾Ý¿â²Ù×÷¡£Èç¹ûÏîÄ¿µÄSP½Ï¶à£¬ÊéдÓÖûÓÐÒ»¶¨µÄ¹æ·¶£¬½«»áÓ°ÏìÒÔºóµÄϵͳά»¤ ......
×î½üÓõ½ÈÕÆÚ·¶Î§µÄ²éѯ£¬Óõ½ÁËbetween£¬µ«ÊÇ·¢ÏÖÈç¹ûÈÕÆÚ´øʱ¼äµÄ»°£¬BETWEEN '2010-1-4' AND
'2010-1-4'ÕâÑùµÄÓï¾äÊDz鲻µ½Êý¾ÝµÄ£¬ºóÀ´Ïëµ½ÁËÒ»ÖָĽø·½·¨£¬¹©´ó¼Ò²Î¿¼¡£
ÈçÏ£º
BETWEEN '2010-1-4' AND DATEADD(day, 1, '2010-1-4')
ÓÃÁËDATEADDÒÔºó£¬Ð§¹ûºÜ²»´í ......