Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ʹÓÃSQL ServerµÄOPENROWSETº¯Êý

¡¡Äã¿ÉÄܳ£³£»áÐèÒªÔËÐÐÒ»¸öad hoc²éѯ´ÓÔ¶³ÌOLE DBÊý¾ÝÔ´ÌáÈ¡Êý¾Ý£¬»òÕßÅúÁ¿ÏòSQL Server±íµ¼ÈëÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬Äã¿ÉÒÔÔÚT-SQL(Transact-SQL£¬Î¢Èí¶ÔSQLµÄÀ©Õ¹)ÖÐÓÃOPENROWSETº¯Êý¸øÊý¾ÝÔ´´«ÈëÒ»¸öÁ¬½Ó´®ºÍ²éѯÀ´ÌáÈ¡ÐèÒªµÄÊý¾Ý¡£
¡¡¡¡Äã¿ÉÄܳ£³£»áÐèÒªÔËÐÐÒ»¸öad hoc²éѯ´ÓÔ¶³ÌOLE DBÊý¾ÝÔ´ÌáÈ¡Êý¾Ý£¬»òÕßÅúÁ¿ÏòSQL Server±íµ¼ÈëÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬Äã¿ÉÒÔÔÚT-SQL(Transact-SQL£¬Î¢Èí¶ÔSQLµÄÀ©Õ¹)ÖÐÓÃOPENROWSETº¯Êý¸øÊý¾ÝÔ´´«ÈëÒ»¸öÁ¬½Ó´®ºÍ²éѯÀ´ÌáÈ¡ÐèÒªµÄÊý¾Ý¡£
¡¡¡¡Äã¿ÉÒÔʹÓÃOPENROWSETº¯Êý´ÓÈκÎÖ§³Ö×¢²áOLE DBµÄÊý¾ÝÔ´»ñÈ¡Êý¾Ý£¬±ÈÈç´ÓSQL Server»òAccessµÄÔ¶³ÌʵÀýÖÐÌáÈ¡Êý¾Ý¡£Èç¹ûÄãÓÃOPENROWSET´ÓSQL ServerʵÀýÖлñÈ¡Êý¾Ý£¬¸ÃʵÀý±ØÐëÅäÖÃΪÔÊÐíad hoc·Ö²¼Ê½²éѯ¡£
¡¡¡¡ÒªÅäÖÃÔ¶³ÌSQL ServerʵÀýÖ§³Öad hoc²éѯ£¬ÐèҪʹÓÃϵͳ´æ´¢¹ý³Ìsp_configureÏÈÉèÖÃadvanced options£¬ÔÙÆôÓÃAd Hoc Distributed Queries(ad hoc·Ö²¼Ê½²éѯ)¡£Çë¿´ÏÂÃæµÄT-SQL½Å±¾£º
¡¡¡¡EXEC sp_configure 'show advanced options', 1;
¡¡¡¡GO
¡¡¡¡RECONFIGURE;
¡¡¡¡GO
¡¡¡¡EXEC sp_configure 'Ad Hoc Distributed Queries', 1
¡¡¡¡GO
¡¡¡¡RECONFIGURE;
¡¡¡¡GO
 ¡¡¡¡Òª×¢ÒâµÄÊÇ£¬ÔÚÔËÐÐÍê´æ´¢¹ý³ÌÖ®ºó£¬Äã±ØÐëÔËÐГRECONFIGURE”ÃüÁî¡£ Ò»µ©ÄãÅäÖúÃÁËÔ¶³ÌSQL ServerʵÀý£¬Äã¾Í¿ÉÒÔ¶ÔËüʹÓÃOPENROWSETº¯Êý¡£Õâ¸öº¯Êý¿ÉÒÔÔÚSELECTÓï¾äµÄfrom´Ó¾äÀïʹÓá£ÏÂÃæµÄÀý×ÓÏÔʾÁ˸ú¯ÊýµÄ»ù±¾Óï·¨£º
¡¡¡¡OPENROWSET('provider', 'connection string', target)
 ¡¡¡¡¿ÉÒÔ¿´µ½£¬Õâ¸öº¯ÊýÓÐÈý¸ö²ÎÊý£º
¡¡¡¡·Provider —— ijÌض¨Êý¾ÝÔ´Ö§³ÖµÄOLE DBÌṩÕßµÄÈË»úÓѺÃÃû³Æ(ProgID)¡£ProviderµÄÃû×Ö±ØÐëÓõ¥ÒýºÅÀ¨ÆðÀ´¡£
¡¡¡¡·Connection string —— Á¬½Ó´®¡£ËüÊÇÓë¾ßÌåÌṩÕßproviderÏà¹ØµÄ×Ö·û´®£¬°üÀ¨Á¬½Óµ½¸ø×Ö·û´®ÖÐÖ¸¶¨µÄÊý¾ÝÔ´ËùÐèÒªµÄϸ½ÚÐÅÏ¢¡£¸ù¾ÝproviderµÄ²»Í¬£¬Á¬½Ó´®ÐÅÏ¢ÐèÒªÓÃÒ»¶Ô»ò¶à¶Ôµ¥ÒýºÅÀ¨ÆðÀ´¡£
¡¡¡¡·Target —— target²ÎÊý¿ÉÒÔʹһ¸öÊý¾Ý¿â¶ÔÏó»òÕßÒ»¸ö²éѯ¡£
¡¡¡¡·Object —— Êý¾Ý¿â¶ÔÏóµÄÃû×Ö£¬±ÈÈç±í»òÕßÊÓͼµÄÃû³Æ¡£¶ÔÏóµÄÍêÕûÃû×Ö±ØÐëÌṩ£¬ËüÃDz»ÐèÒªÓõ¥ÒýºÅÀ¨ÆðÀ´¡£
¡¡¡¡·Query —— queryÊÇ´ÓÔ¶³ÌÊý¾ÝÔ´ÌáÈ¡Êý¾ÝµÄSelectÓï¾ä¡£Query±ØÐëÓõ¥ÒýºÅÀ¨ÆðÀ´¡£
¡¡¡¡ÏÂÃæµÄÀý×ÓչʾÁËOPENROWSETº¯ÊýµÄÓ÷¨£º
¡¡


Ïà¹ØÎĵµ£º

Êý¾Ý×ֵ䣨SQLÓï¾ä£©

declare @tmp table
(
id int identity(1,1),
TableName varchar(100),
Column_name varchar(100),
Type varchar(50),
Lenght int,
Scale int,
Nullable varchar(1),
Defaults varchar(4000),
PrimaryKey varchar(1)
)
select iid = identity(int,1,1), * into #a from SysObjects where xtype = 'U'
declare ......

sql server 2008 ´´½¨Óû§

 
ÕâÁ½ÌìÓõ½ÁË sql server 2008 £¬Ö÷ÒªÊǽ¨Êý¾Ý¿â£¬½¨±íºÍ´´½¨Óû§¡£
 
ÔÚ “Windows Éí·ÝÑéÖ¤”   Ï£¬´´½¨ÁËÊý¾Ý¿âºÍ Óû§£¬È»ºóÓà SQL Server Éí·ÝÑéÖ¤  µÇ¼ £¬È´Ìáʾ ´íÎó 18452£¬
ÕÒÁËÒ»ÏÂ×ÊÁÏ ¸Ä·¨ ÈçÏ£º
[ÎÞ·¨Á¬½Óµ½·þÎñÆ÷ ·þÎñÆ÷£ºÏûÏ¢18452£¬ ¼¶±ð16£¬×´Ì¬1 [Microsof ......

Oracle SQL_TRACEʹÓÃС½á

Ò»¡¢¹ØÓÚ»ù´¡±í
Oc_COJ^c680758
rd-A6z\&[1R1] H680758
Oracle
10G֮ǰ£¬ÆôÓÃAUTOTRACE¹¦ÄÜÐèÒªÊÖ¹¤´´½¨plan_table±í£¬´´½¨½Å±¾Îª$ORACLE_HOME/rdbms/admin
/utlxplan.sql¡£µ«ÔÚ10gÖУ¬ÒѾ­Ä¬ÈÏ´´½¨ÁËPLAN_TABLE$µÄ»ù±í£¬²¢ÒÔpublicÓû§´´½¨ÁËÏàÓ¦µÄͬÒå´ÊPUBLIC¡£ITPUB¸öÈË¿Õ¼äDR#IlHrT
ITPUB¸ ......

SQL SERVER ÓÃsqlÓï¾äÈçºÎ»ñµÃµ±Ç°ÏµÍ³Ê±¼ä


SQL SERVER 2000ÓÃsqlÓï¾äÈçºÎ»ñµÃµ±Ç°ÏµÍ³Ê±¼ä
¾ÍÊÇÓÃGETDATE();
SqlÖеÄgetDate()2008Äê01ÔÂ08ÈÕ ÐÇÆÚ¶þ 14:59
Sql Server ÖÐÒ»¸ö·Ç³£Ç¿´óµÄÈÕÆÚ¸ñʽ»¯º¯Êý
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2008 10:57AM
Select CONVERT(varchar(100), GETDATE(), 1): 05/16/08
Select CONVERT(varchar(100), ......

Êý¾Ý¿â»ù±¾ SQLÓï¾ä´óÈ«

Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
Create DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice disk, testBack, c:mssql7backupMyNwind_1.dat
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢Ë ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ