SQLÊý¾ÝÖÐÔËÐÐcmdÃüÁî
ÔÚsql²éѯ·ÖÎöÆ÷ÀïÃæÊDz»ÄÜÖ±½ÓÔËÐÐcmdÃüÁîµÄ
µ«ÊÇSQL¸ø³öÁËÒ»¸ö½Ó¿Ú
--´ò¿ª¸ß¼¶ÉèÖÃ
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
--´ò¿ªxp_cmdshellÀ©Õ¹´æ´¢¹ý³Ì
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
Ê×ÏÈ ´ò¿ªÒ»Ð©ÅäÖÃ
È»ºóÖ´ÐÐÄãÒªÔËÐÐcmdÃüÁî
exec master..xp_cmdshell 'net start "computer browser"'
RECONFIGURE
--Ìí¼ÓÍøÂçÇý¶¯Æ÷Ó³Éä
exec master..xp_cmdshell 'net use z: \\192.168.0.3\F$\DataBase "ÃÜÂë" /user:192.168.0.3£¨IP£©\administrator£¨µÇ½Óû§Ãû£©
È»ºó¹Ø±ÕÏàÓ¦µÄ³ÌÐò
--ɾ³ýÓ³Éä
exec master..xp_cmdshell 'net use z: /delete'
--¹Ø±Õxp_cmdshellÀ©Õ¹´æ´¢¹ý³Ì¡¢¸ß¼¶ÉèÖÃ
EXEC sp_configure 'xp_cmdshell', 0
RECONFIGURE
EXEC sp_configure 'show advanced options', 0
RECONFIGURE
Ïà¹ØÎĵµ£º
CREATE proc sqlToMultiExcelFile
@sqlstr nvarchar(4000), --²éѯÓï¾ä,Èç¹û²éѯÓï¾äÖÐʹÓÃÁËorder by ,Çë¼ÓÉÏtop 100 percent
@primaryKey varchar(100),--·ÖÒ³Ö÷¼ü×Ö¶Î
@path nvarchar(1000), --Îļþ´æ·ÅĿ¼
@fname nvarchar(250), --ÎļþÃû
@sheetname varchar(250)='sheet1' --Òª´´½¨µÄ¹¤×÷±íÃû,Ä ......
1: ɾ³ýLOG (ɾ³ýlogÎļþ£¬¸½¼Óʱ×Ô¶¯Öؽ¨logÎļþ£¬ÒÔ´Ë·½Ê½À´Çå¿ÕÈÕÖ¾)
1) ·ÖÀëÊý¾Ý¿â ÆóÒµ¹ÜÀíÆ÷££¾·þÎñÆ÷££¾Êý¾Ý¿â££¾ÓÒ¼ü££¾·ÖÀëÊý¾Ý¿â
2) ɾ³ýLOGÎļþ
3) ¸½¼ÓÊý¾Ý¿â ÆóÒµ¹ÜÀíÆ÷££¾·þÎñÆ÷££¾Êý¾Ý¿â££¾ÓÒ¼ü££¾¸½¼ÓÊý¾Ý¿â
´Ë·¨Éú³ ......
create table tb (ptoid int,proclassid int,proname varchar(10))
insert tb
select 1,1,'Ò·þ1'
union all
select 2,2,'Ò·þ2'
union all
select 3,3,'Ò·þ3'
union all
select 4,3,'Ò·þ4'
union all
select 5,2,'Ò·þ5'
union all
select 6,2,'Ò·þ6'
union all
select 7,2,'Ò·þ7'
union all
select 8 ......
Standard Security:
"Data Source=Aron1;Initial
Catalog=pubs;User Id=sa;Password=asdasd;"
- or -
"Server=Aron1;Database=pubs;User
ID=sa;Pass ......
ÔÎĵØÖ·£ºhttp://www.blogjava.net/xingcyx/archive/2007/01/09/92638.html
ʹÓÃoracleµÄ10046ʼþ¸ú×ÙSQLÓï¾ä
ÎÒÃÇÔÚ·ÖÎöÓ¦ÓóÌÐòÐÔÄÜÎÊÌâµÄʱºò£¬¸ü¶àµØÐèÒª¹Ø×¢ÆäÖÐSQLÓï¾äµÄÖ´ÐÐÇé¿ö£¬ÒòΪͨ³£Ó¦ÓóÌÐòµÄÐÔÄÜÆ¿¾±»áÔÚÊý¾Ý¿âÕâ±ß£¬Òò´ËÊý¾Ý¿âµÄsqlÓï¾äÊÇÎÒÃÇÓÅ»¯µÄÖص㡣ÀûÓÃOracleµÄ10046ʼþ£¬¿ÉÒÔ¸ú×ÙÓ¦ÓóÌÐòËùÖ´ ......