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

·ÀÖ¹SQL SERVERµÄʼþ̽²éÆ÷¸ú×Ù³ÌÐòÖÐSQL½Å±¾

ÈçºÎ·ÀÖ¹³ÌÐòÖÐSQL½Å±¾±»SQL SERVERµÄʼþ̽²éÆ÷¸ú×Ù£¬±£ÕÏ×Ô¼ºµÄÈí¼þ²»±»ËûÈË·ÖÎö£¿
ÏÂÃæÊÇÒ»¸öÍ£Ö¹ËùÓÐSQLSERVERµÄ¸ú×ÙÆ÷µÄ½Å±¾(Á½ÖÖ·½·¨µÄÔ­ÀíÏàͬ)£º
µÚÒ»ÖÖ·½·¨£º
procedure SQLCloseAllTrack;
const
sql = 'declare @TID integer ' +
'declare Trac Cursor For ' +
'SELECT Distinct Traceid from :: fn_trace_getinfo(default) ' +
'open Trac ' +
'Fetch Next from Trac into @TID ' +
'while @@fetch_status=0 ' +
'begin ' +
' exec sp_trace_setstatus @TID,0 ' +
' exec sp_trace_setstatus @TID,2 ' +
' Fetch Next from Trac into @TID ' +
'end ' +
'Close Trac ' +
'deallocate Trac';
begin
//Í£Ö¹ËùÓÐSQLSERVERµÄ¸ú×ÙÆ÷,ÒÔ·ÀÖ¹³ÌÐò±»別È˸ú×Ù
ExecSql(sql);
end;
µÚ¶þÖÖ·½·¨£º
with faq1 do
begin
Close;
sql.Clear;
sql.add('declare @t_count int');
sql.add('set @t_count=1');
sql.add('while exists(SELECT * from ::::fn_trace_geteventinfo(@t_count))');
sql.add('begin');
sql.add('exec sp_trace_setstatus @t_count,0');
sql.add('set @t_count=@t_count+1');
sql.add('end');
try
execSQL;
except;
end;
close;sql.Clear;
end;
end;


Ïà¹ØÎĵµ£º

SQL ³£ÓÃµÄ Ôö¡¢É¾¡¢¸Ä¡¢²é »¹ÊÇÀμÇÓÚÐÄ àÞ

¼¸¸ö¼òµ¥µÄ»ù±¾µÄsqlÓï¾ä
 
Ñ¡Ôñ£ºselect * from table1 where ·¶Î§
²åÈ룺insert into table1(field1,field2) values(value1,value2)
ɾ³ý£ºdelete from table1 where ·¶Î§
¸üУºupdate table1 set field1=value1 where ·¶Î§
²éÕÒ£ºselect * from table1 where field1 like ’%value1%’
ÅÅÐò£ ......

SQL×éºÏ²éѯ¼°ÏȺó˳Ðò¶ÔЧÂʵÄÓ°Ïì

ÔÚSQL¿ç±í×éºÏ²éѯ´æÔÚЧÂÊÎÊÌ⣬¾ÙÀý±ÈÈç
delete from media_source where movie_id in ( select media_id from media where type=2 ) and origin = 3;
ºÍ
delete from media_source where origin = 3 and movie_id in ( select media_id from media where type=2 );
µÄЧÂÊÊDz»Ò»ÑùµÄ¡£
Èôorigin=3µÄÇé¿öÏÂmedia_so ......

SQL Server·ÖÒ³3ÖÖ·½°¸

 SQL Server·ÖÒ³3ÖÖ·½°¸±ÈÆ´
´ËתÔØÔ´×ÔÀîºé¸ùµÄblog.×÷ÕßÊÇ΢ÈíµÄMVP!Ï£Íû´ó¼Ò²Î¿¼ÒÔÏÂ3ÖÖ·½°¸,°´Êµ¼ÊÇé¿öÑ¡Ôñ!
½¨Á¢±í£º
CREATE TABLE [TestTable] (
 [ID] [int] IDENTITY (1, 1) NOT NULL ,
 [FirstName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
 [LastName] [nvarchar] (100) ......

sqlÓï¾äÓÅ»¯30Àý×Ó

ÔÚSQLÓï¾äÓÅ»¯¹ý³ÌÖУ¬ÎÒÃǾ­³£»áÓõ½hint,ÏÖ×ܽáÒ»ÏÂÔÚSQLÓÅ»¯¹ý³ÌÖг£¼ûOracle HINTµÄÓ÷¨£º
1. /*+ALL_ROWS*/
±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÍÌÍÂÁ¿,ʹ×ÊÔ´ÏûºÄ×îС»¯.
ÀýÈç:
SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
2. /*+FIRST_ROWS*/
±íÃ÷¶ÔÓï¾ä¿éÑ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ