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 [¿Í»§×Ê
Ïà¹ØÎĵµ£º
±¾ÎĽéÉÜÁËSQL Server 2008ÀïһЩеÄÌØµãÒÔ¼°·¢ÏÖµÄһЩ¾«ÃîÖ®´¦……
¡¡¡¡°²×°
¡¡¡¡SQL
Server
2008µÄÉèÖúͰ²×°Ò²ÓÐËù¸Ä½ø¡£ÅäÖÃÊý¾ÝºÍÒýÇæÎ»ÒѾ·Ö¿ªÁË£¬ËùÒÔËüʹ´´½¨»ù±¾µÄδÅäÖÃϵͳµÄ´ÅÅÌͼÏñ±äµÃ¿ÉÄÜÁË£¬Ëüʹ·Ö²¼µ½¶à¸ö·þÎñÆ÷±äµÃ¸üÈÝÒ×ÁË¡£
´Ó΢ÈíµÄÕ¾µãÒ²¿ÉÒÔÕÒµ½°²×°¿ÉÓõÄ×îиüС£ÁíÒ»¸öÌØµ ......
¹Ì¶¨³¤¶È(char)Óë¿É±ä³¤¶È(varchar)×Ö·ûÊý¾ÝÀàÐÍ
char[(n)]
³¤¶ÈΪn¸ö×ֽڵĹ̶¨³¤¶ÈÇÒ·ÇUnicodeµÄ×Ö·ûÊý¾Ý¡£n±ØÐëÊÇÒ»¸ö½éÓÚ1ºÍ8,000Ö®¼äµÄÊýÖµ¡£´æ´¢´óСΪn¸ö×Ö½Ú¡£charÔÚSQL-92ÖеÄͬÒå´ÊΪcharacter¡£
varchar[(n)]
³¤¶ÈΪn¸ö×ֽڵĿɱ䳤¶ÈÇÒ·ÇUnicodeµÄ×Ö·ûÊý¾Ý¡£n±ØÐëÊÇÒ»¸ö½éÓÚ1ºÍ8,000Ö®¼äµÄÊýÖµ¡£´æ´¢´óСΪ ......
×ªÔØ×Ô£ºhttp://www.cnblogs.com/leonbao/archive/2008/03/07/1094821.html
¹ØÓÚSQL ServerÊý¾Ý¿âÉè¼ÆµÄ¸ÐÎò£¬ÇëÖ¸½Ì
ÓÐÎÊÌâµÄʱºò£¬ÎÒ¾³£»ØÀ´²©¿Í԰ѰÕҴ𰸣¬¾Ã¶ø¾ÃÖ®£¬×ܽáÁËһЩ¶«Î÷¡£
Íý×ԷƱ¡£¬Çë´ó¼Ò¶àÖ¸³ö´íÎ󣬲¢¸ø³öÒâ¼û
Êý¾Ý¿âÉè¼ÆÈý·¶Ê½»ù±¾ÔÔò
µÚÒ»·¶Ê½£ºÊý¾Ý¿â±íÖеÄ×ֶζ¼Êǵ¥Ò»ÊôÐԵ쬲»¿ÉÔÙ·Ö¡£Õâ ......
--Èç¹ûÊÇʵ±í¿ÉÒÔÓÃ
if exists (select * from sysobjects where id = object_id(N'[dbo].[±íÃû]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[±íÃû]
--Èç¹ûÊÇÁÙʱ±í¿ÉÒÔÓÃ(˵Ã÷,Èç¹ûÓòéÕÒʵ±í·½·¨À´´òÁÙʱ±í»áÕÒ²»µ½.·¢²¼Çø±ð¶Ô´ú.)
if object_id('tempdb..##temp') is not null
......
SELECT ROWNUM AS ID
,TO_CHAR(SYSDATE + ROWNUM / 24 / 3600, 'yyyy-mm-dd hh24:mi:ss') AS INC_DATETIME
,TRUNC(DBMS_RANDOM.VALUE(0, 100)) AS RANDOM_ID
,DBMS_RANDOM.STRING('x', 20) RANDOM_STRING
from DUAL
CONNECT BY LEVEL <= 10;
SELECT '('||WMSYS.WM_CONCAT(':P' || ROWNUM)| ......