ʹÓÃSQL Serverµ¼Èë/µ¼³öExcel
ʹÓÃSQL Serverµ¼Èë/µ¼³öExcel,°üº¬²¿·Ö´íÎóÐÅÏ¢´¦Àí·½·¨;
²Ù×÷ÊÖ¼Ç,Áô´Ë±¸²é
/*
µ¼Èë
*/
--´íÎóÐÅÏ¢ÈçÏÂʱ£º
--Msg 15281, Level 16, State 1, Line 2
--SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.
--ÇëÑ¡ÔñÖ´ÐÐÏÂÃæÓï¾ä,ÐÞ¸ÄĬÈÏÅäÖÃ,ÔÚ½øÐе¼Èë²Ù×÷
-- begin
sp_configure 'show advanced options',1
RECONFIGURE WITH override
go
sp_configure 'Ad Hoc Distributed Queries',1 -- 1:ÆôÓÃ,ĬÈÏ0:½ûÓÃ
RECONFIGURE WITH override
go
EXEC sp_configure;
go
-- end
-- ²éѯ
select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=D:\ExcelSheet1.xls',sheet1$)
go
-- ²éѯ²¢µ¼Èë
select * into ExcelSheet from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=D:\ExcelSheet1.xls',sheet1$)
go
/*
µ¼³ö
*/
--´íÎóÐÅÏ¢ÈçÏÂʱ£º
--Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
--SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.
--ÇëÑ¡ÔñÖ´ÐÐÏÂÃæÓï¾ä,ÐÞ¸ÄĬÈÏÅäÖÃ,ÔÚ½øÐе¼³ö²Ù×÷
-- begin
sp_configure 'show advanced options',1
RECONFIGURE WITH override
go
sp_configure 'xp_cmdshell',1 -- 1:ÆôÓÃ,ĬÈÏ0:½ûÓÃ
RECONFIGURE WITH override
go
EXEC sp_configure;
go
-- end
--Ìí¼Óµ½ÏÖÔÚExcelÎĵµ
insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=D:\ExcelSheet.xls',sheet1$)
go
--´øÁ¬½ÓÐÅÏ¢µ¼³ö
EXEC master..xp_cmd
Ïà¹ØÎĵµ£º
----start
SQL(Structured Query Language)£¬Ò²¾ÍÊǽṹ»¯²éѯÓïÑÔ£¬Ëü±»Éè¼ÆÓÃÀ´²Ù×÷¼¯ºÏµÄ£¬ÊǷǹý³Ì»¯µÄÓïÑÔ¡£Ëæ×ÅÓ¦ÓóÌÐòµÄ·¢Õ¹£¬ÒµÎñÂß¼Ô½À´Ô½¸´ÔÓ£¬´«Í³µÄSQLÒѾ²»ÄÜÂú×ãÈËÃǵÄÒªÇó£¬ÓÚÊÇÈËÃǶÔSQL½øÐÐÁËÀ©Õ¹£¬Ê¹Ëü¾ßÓÐÁ˹ý³Ì»¯µÄÂß¼£¬¼´£ºSQL PL¡£SQL PLµÄÈ«³ÆÊÇ SQL Procedural Language£ ......
×ÜÓû§±í:select count(*) ×ܱíÊý from sysobjects where xtype='u'
×ÜÓû§±íºÍϵͳ±í:select count(*) ×ܱíÊý from sysobjects where xtype in('u','s')
×ÜÊÓͼÊý:select count(*) ×ÜÊÓͼÊý from sysobjects where xtype='v'
×Ü´æ´¢¹ý³ÌÊý:select count(*) ×Ü´æ´¢¹ý³ÌÊý from sysobjects where xtype='p'
×Ü´¥·¢Æ÷Êý:s ......
Ñ¡Ôñ×Ô CSDN
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:\tes ......
Microsoft SQL Server
2008ºÍMicrosoftÊý¾Ýƽ̨Ϊ¿ª·¢ÈËÔ±ÌṩÁËÒ»¸ö×ۺϵıà³Ì¼Ü¹¹£¬ÓÃÓÚ´´½¨Õë¶ÔÒÆ¶¯É豸¡¢×ÀÃæµçÄÔ¡¢Web·þÎñÆ÷£¬ºÍÆóÒµ·þÎñÆ÷µÄ»ùÓÚÊý¾ÝµÄ½â
¾ö·½°¸¡£Õâ¸öÊý¾Ý±à³Ì»·¾³½«Êý¾Ý·ÃÎʺ͹ÜÀí¼¯³Éµ½Ò»¸öÓ¦ÓóÌÐòµÄÒµÎñÂß¼ÖУ¬´Ó¶øÌá¸ßÁË¿ª·¢ÈËÔ±µÄÉú²úÁ¦¡£ËüÌṩÁËÒ»¸öÓÃÓÚ¶ÔÒì¹¹Êý¾ÝÔ´µÄÊý¾Ý·ÃÎʺ͹ÜÀí
µÄ ......
±¾ÎĽÚÑ¡×ÔMSDNµÄÎÄÕ¡¶ÎåÖÖÌá¸ß SQL ÐÔÄܵķ½·¨¡·£¬Ìá³öÈçºÎÌá¸ß»ùÓÚSQL ServerÓ¦ÓóÌÐòµÄÔËÐÐЧÂÊ£¬·Ç³£ÖµµÃÍÆ¼ö¡£¶ÔһЩTrafficºÜ¸ßµÄÓ¦ÓÃϵͳ¶øÑÔ£¬ÈçºÎÌá¸ßºÍ¸Ä½øSQLÖ¸ÁÊǷdz£ÖØÒªµÄ£¬Ò²ÊÇÒ»¸öºÜºÃµÄÍ»ÆÆµã¡£
*ÎÄÕÂÖ÷Òª°üÀ¨ÈçÏÂһЩÄÚÈÝ£¨Èç¸ÐÐËȤ£¬ÇëÖ±½Ó·ÃÎÊÏÂÃæµÄURLÔĶÁÍêÕûµÄÖÐÓ¢ÎÄÎĵµ£©£º
1, ´Ó INSE ......