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

¾«Ãî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 ÔËËã·ûͨ¹ý°üÀ


Ïà¹ØÎĵµ£º

SQL SERVERÈÕÆÚʱ¼äº¯Êý

 À´Ô´http://hi.baidu.com/smilevt/blog/item/04bddeef0fe3f42e2cf5348b.htmlÕâÀﻹÓкܶàsql serverµÄÌû×Ó
1. µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
select getdate()
2. dateadd ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
ÀýÈ磺ÏòÈÕÆÚ¼ÓÉÏ2Ìì
select dateadd(day,2,'2004-10-15') --·µ»Ø£º2004-10-17 00:00:00. ......

shellÖÐʹÓÃSQLʵÏÖ²éѯ

 ÏÈ°ÑÎı¾½øÐиñʽ´¦Àí£¬È»ºóÒÔ¿Õ¸ñΪ·Ö¸ô·û£¬È¡µÚ¶þ¸ö¿Õ¸ñºóµÄ×Ö´®£¬ÅÅÐò£¬È¥ÖØ£¬ÔÙ½µÐòÅÅÁУ¬È¡Ç°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] ......

Ôõô²¶»ñ×Ô¼ºsessionÖ´ÐеÄsql£¬½øÐÐÉîÈë¸ú×Ù

 
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 2005 Analysis Services²¿Êðʱ±¨¸æ´íÎó

 Êý¾ÝÔ´......°üº¬ÎÞ·¨ÓÃÓÚ´¦Àí²Ù×÷µÄ ImpersonationMode¡£
½â¾ö·½·¨£º
·þÎñÆ÷Á¬½Ó¸ÄΪ“ʹÓ÷þÎñÕË»§”¡£
¾ßÌå²Ù×÷£º
ÔÚÊý¾ÝÔ´ÀïµÄÏîÄ¿Éϵã»÷ÓÒ¼ü->´ò¿ª->Êý¾ÝÔ´Éè¼ÆÆ÷ £¬ Ñ¡Ôñ“Ä£ÄâÐÅÏ¢”±êÇ©->Ñ¡Ôñ“ʹÓ÷þÎñÕË»§”£¬È·¶¨£¬Ö´Ðв¿Êð¡£ ......

SQL Server 2005°²È«ÉèÖÃÖ¸ÄÏ

 ¡¡¡¡×ܵÄÀ´Ëµ£¬MS SQL 2005µÄ°²È«ÐÔ±ÈSQL 2000ҪǿÉϲ»ÉÙ£¬²»¹ýĬÈÏÉèÖû¹ÊÇÓкÍÔ­À´Ò»ÑùµÄ©¶´£¬ÏÂÃæÎÒÃÇÀ´ÐÞ¸ÄÒ»ÏÂĬÈÏÉèÖá£
¡¡¡¡1¡¢ÐÞ¸ÄĬÈÏ£Ó£ÁÃÜÂë¡£
¡¡¡¡°²×°MSSQLʱʹÓûìºÏģʽ£¬µ±È»SAÃÜÂë×îºÃ²»ÄÜΪ¿Õ£¬ÔÚSQL2005ÖУ¬¿ÉÒÔ¶ÔSAÕâ¸ö³¬¼¶Óû§Ãû½øÐÐÐ޸Ļòɾ³ý¡£
use master
ALTER LOGIN [ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ