¾«ÃîSQLÓï¾ä
1.°´ÐÕÊϱʻÅÅÐò:
Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.·ÖÒ³SQLÓï¾ä
select * from(select (row_number() OVER (ORDER BY tab.ID Desc)) as rownum,tab.* from ±íÃû As tab) As t where rownum between ÆðʼλÖà And ½áÊøλÖÃ
3.»ñÈ¡µ±Ç°Êý¾Ý¿âÖеÄËùÓÐÓû§±í
select * from sysobjects where xtype='U' and category=0
4.»ñȡijһ¸ö±íµÄËùÓÐ×Ö¶Î
select name from syscolumns where id=object_id('±íÃû')
5.²é¿´Óëijһ¸ö±íÏà¹ØµÄÊÓͼ¡¢´æ´¢¹ý³Ì¡¢º¯Êý
select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like '%±íÃû%'
6.²é¿´µ±Ç°Êý¾Ý¿âÖÐËùÓд洢¹ý³Ì
select name as ´æ´¢¹ý³ÌÃû³Æ from sysobjects where xtype='P'
7.²éѯÓû§´´½¨µÄËùÓÐÊý¾Ý¿â
select * from master..sysdatabases D where sid not in(select sid from master..syslogins where name='sa')
»òÕß
select dbid, name AS DB_NAME from master..sysdatabases where sid <> 0x01
8.²éѯijһ¸ö±íµÄ×ֶκÍÊý¾ÝÀàÐÍ
select column_name,data_type from information_schema.columns
where table_name = '±íÃû'
9.ʹÓÃÊÂÎñ
ÔÚʹÓÃһЩ¶ÔÊý¾Ý¿â±íµÄÁÙʱµÄSQLÓï¾ä²Ù×÷ʱ£¬¿ÉÒÔ²ÉÓÃSQL SERVERÊÂÎñ´¦Àí£¬·ÀÖ¹¶ÔÊý¾Ý²Ù×÷ºó·¢ÏÖÎó²Ù×÷ÎÊÌâ
¿ªÊ¼ÊÂÎñ
Begin tran
Insert Into TableName Values(…)
SQLÓï¾ä²Ù×÷²»Õý³££¬Ôò»Ø¹öÊÂÎñ¡£
»Ø¹öÊÂÎñ
Rollback tran
SQLÓï¾ä²Ù×÷Õý³££¬ÔòÌá½»ÊÂÎñ£¬Êý¾ÝÌá½»ÖÁÊý¾Ý¿â¡£
Ìá½»ÊÂÎñ
Commit tran
10. °´È«ÎÄÆ¥Å䷽ʽ²éѯ
×Ö¶ÎÃû LIKE N'%[^a-zA-Z0-9]China[^a-zA-Z0-9]%'
OR ×Ö¶ÎÃû LIKE N'%[^a-zA-Z0-9]China'
OR ×Ö¶ÎÃû LIKE N'China[^a-zA-Z0-9]%'
OR ×Ö¶ÎÃû LIKE N'China
11£®¼ÆËãÖ´ÐÐSQLÓï¾ä²éѯʱ¼ä
declare @d datetime
set @d=getdate()
select * from SYS_ColumnProperties select [Óï¾äÖ´Ðл¨·Ñʱ¼ä(ºÁÃë)]=datediff(ms,@d,getdate())
12¡¢ËµÃ÷£º¼¸¸ö¸ß¼¶²éѯÔËËã´Ê
A£º UNION ÔËËã·û
UNION ÔËËã·ûͨ¹ý×éºÏÆäËûÁ½¸ö½á¹û±í£¨ÀýÈç TABLE1 ºÍ TABLE2£©²¢ÏûÈ¥±íÖÐÈκÎÖظ´ÐжøÅÉÉú³öÒ»¸ö½á¹û±í¡£µ± ALL Ëæ UNION Ò»ÆðʹÓÃʱ£¨¼´ UNION ALL£©£¬²»Ïû³ýÖظ´ÐС£Á½ÖÖÇé¿öÏ£¬ÅÉÉú±íµÄÿһÐв»ÊÇÀ´×Ô TABLE1 ¾ÍÊÇÀ´×Ô TABLE2¡£
B£º EXCEPT ÔËËã·û
EXCEPT ÔËËã·ûͨ¹ý°üÀ
Ïà¹ØÎĵµ£º
ÏÈ°ÑÎı¾½øÐиñʽ´¦Àí£¬È»ºóÒÔ¿Õ¸ñΪ·Ö¸ô·û£¬È¡µÚ¶þ¸ö¿Õ¸ñºóµÄ×Ö´®£¬ÅÅÐò£¬È¥ÖØ£¬ÔÙ½µÐòÅÅÁУ¬È¡Ç°5¸ö
arr=($(cat 0100055F_Detail.txt|sed -e '/:/d'|awk -F ' ' '{print$2}'|sort|uniq -c|sort -nr|head -5|awk '{print $2}'))
len=${#arr[@]} »ñÈ¡Êý×鳤¶È
for((i=0;i<$len;i++))
do
echo ${arr[$i] ......
alter session set timed_statistics = true; --¿ÉÑ¡
alter session set max_dump_file_size = unlimited; --¿ÉÑ¡£¬·ÀÖ¹dumpĿ¼·Å²»ÏÂ
-- To enable the trace event 10046
alter session set events '10046 trace name context forever, level 8';
--ÉèÖÃTRACEFILE_IDENTIFIER²ÎÊýÖµ£¬ÈÃtraceÎļþ°üÀ¨MyTrac ......
ÔÚµ÷Ó÷þÎñÆ÷ºóÒª¼ÌÐøÔÚ·þÎñÆ÷Öб£ÁôÊý¾Ýͨ³£ºÜÄÑ£¬Äã¿ÉÒÔÓÃSQL ServerÀ´½øÐлỰ״̬¹ÜÀí(Óû§»á»°Êý¾Ý)¡£ÒÔϽÌÄãÔõÑùÓÃËüÀ´½øÐйÜÀí¡£
¡¡¡¡ÔÚÒ³Ã濪·¢ÖУ¬ÔÚ·þÎñÆ÷µ÷ÓÃÀï±£ÁôÊý¾ÝÊÇÒ»¸ö³£¼ûµÄ²»ºÃ½â¾öµÄÄÑÌâ¡£ÄãÒ²ÐíÐèҪΪÄãµÄÓ¦ÓóÌÐò»òÌØÊâÓû§µÄ»á»°±£´æÐÅÏ¢¡£´æ´¢ÕâÑùµÄÊý¾Ý±»³ÆΪ״̬¹ÜÀí£¬ASP.NETΪÄãÌṩ ......
1 Âß¼Êý¾Ý¿âºÍ±íµÄÉè¼Æ
¡¡¡¡Êý¾Ý¿âµÄÂß¼Éè¼Æ¡¢°üÀ¨±íÓë±íÖ®¼äµÄ¹ØϵÊÇÓÅ»¯¹ØϵÐÍÊý¾Ý¿âÐÔÄܵĺËÐÄ¡£Ò»¸öºÃµÄÂß¼Êý¾Ý¿âÉè¼Æ¿ÉÒÔΪÓÅ»¯Êý¾Ý¿âºÍÓ¦ÓóÌÐò´òÏÂÁ¼ºÃµÄ»ù´¡¡£
¡¡¡¡±ê×¼»¯µÄÊý¾Ý¿âÂß¼Éè¼Æ°üÀ¨ÓöàµÄ¡¢ÓÐÏ໥¹ØϵµÄÕ±íÀ´´úÌæºÜ¶àÁеij¤Êý¾Ý±í¡£ÏÂÃæÊÇһЩʹÓñê×¼»¯±íµÄһЩºÃ´¦¡£
A:ÓÉÓÚ±íÕ£¬Òò´Ë¿É ......