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

sqlÓï¾ä

                            SqlÓï¾ä
 
 1. ˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ£¬Ô´±íÃû£ºa£¬Ð±íÃû£ºb) SQL:select * into bfrom awhere 1<>1;
 2. ˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý£¬Ô´±íÃû£ºa£¬Ä¿±ê±íÃû£ºb) SQL:insert into b(a, b, c)select d, e, ffrom     b;
3. ˵Ã÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä SQL:select a.title, a.username, b.adddatefrom table a,(select max(adddate) adddatefrom table where table.title=a.title) b ¡¡
4. ˵Ã÷£ºÍâÁ¬½Ó²éѯ(±íÃû1£ºa£¬±íÃû2£ºb) SQL:select a.a, a.b, a.c, b.c, b.d, b.ffrom aLEFT OUTJOIN bON a.a= b.c; ¡¡
5. ˵Ã÷£ºÈճ̰²ÅÅÌáÇ°Îå·ÖÖÓÌáÐÑ SQL:select * from Èճ̰²ÅÅwhere datediff(’’minute’’, f¿ª     ʼʱ¼ä,getdate())>5 ¡¡¡¡¡¡¡¡
6. ˵Ã÷£ºÁ½ÕŹØÁª±í£¬É¾³ýÖ÷±íÖÐÒѾ­ÔÚ¸±±íÖÐûÓеÄÐÅÏ¢ SQL:delete from infowhere not exists(select * from infobzwhere info.infid=infobz.infid );
¡¾SQL SERVER Êý¾Ý¿âʵÓÃSQLÓï¾ä¡¿
1.°´ÐÕÊϱʻ­ÅÅÐò:Select * from TableNameOrder By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.·ÖÒ³SQLÓï¾äselect * from(select (row_number()OVER (ORDER BY tab.IDDesc))as rownum,tab.* from ±íÃûAs tab)As twhere rownumbetween ÆðʼλÖÃAnd ½áÊøλÖÃ
3.»ñÈ¡µ±Ç°Êý¾Ý¿âÖеÄËùÓÐÓû§±íselect * from sysobjectswhere xtype='U' and category=0
4.»ñȡijһ¸ö±íµÄËùÓÐ×Ö¶Îselect namefrom syscolumnswhere id=object_id('±íÃû')
5.²é¿´Óëijһ¸ö±íÏà¹ØµÄÊÓͼ¡¢´æ´¢¹ý³Ì¡¢º¯Êýselect a.* from sysobjects a, syscomments bwhere a.id= b.idand b.text like '%±íÃû%'
6.²é¿´µ±Ç°Êý¾Ý¿âÖÐËùÓд洢¹ý³Ìselect nameas ´æ´¢¹ý³ÌÃû³Æfrom sysobjectswhere xtype='P'
7.²éѯÓû§´´½¨µÄËùÓÐÊý¾Ý¿âselect * from master..sysdatabases Dwhere sidnot in(select sidfrom master..sysloginswhere name='sa') »òÕßselect dbid, nameAS DB_NAME from master..sysdatabaseswhere sid<> 0x01
8.²éѯijһ¸ö±íµÄ×ֶκÍÊý¾ÝÀàÐÍselect column_name,data_typefrom information_schema.columnswhere table_name= '±íÃû'
9.ʹÓ


Ïà¹ØÎĵµ£º

ÈçºÎÓÅ»¯SQL ServerÊý¾Ý¿â²éѯ(ת)

 1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)¡¡¡¡
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£¡¡¡¡
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£¡¡¡¡
¡¡¡¡4¡¢ÄÚ´æ²»×ã¡¡¡¡
¡¡¡¡5¡¢ÍøÂçËÙ¶ÈÂý¡¡¡¡
¡¡¡¡6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó£¨¿ÉÒÔ²ÉÓöà´Î²éѯ£¬ÆäËûµÄ·½·¨½µµÍÊý¾ÝÁ¿£©¡¡¡¡
¡¡¡¡7¡¢Ëø»òÕßËÀËø ......

SQL ÈÕÆÚÅ̵ã

DECLARE @dt datetime
SET @dt=GETDATE()
DECLARE @number int
SET @number=3
--1£®Ö¸¶¨ÈÕÆÚ¸ÃÄêµÄµÚÒ»Ìì»ò×îºóÒ»Ìì
--A. ÄêµÄµÚÒ»Ìì
SELECT CONVERT(char(5),@dt,120)+'1-1'
--B. ÄêµÄ×îºóÒ»Ìì
SELECT CONVERT(char(5),@dt,120)+'12-31'
--2£®Ö¸¶¨ÈÕÆÚËùÔÚ¼¾¶ÈµÄµÚÒ»Ìì»ò×îºóÒ»Ìì
--A. ¼¾¶ÈµÄµÚÒ»Ìì
SELECT CON ......

¶¯Ì¬SQL»ù±¾Óï·¨

1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃexecÖ´ÐÐ
Select * from tableName
exec('select * from tableName')
exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
declare @fname varchar(20)
set @fname = 'FiledName'
Select @fname from tab ......

SQLÊý¾Ý¿â£ºÒòΪÎļþ×é 'PRIMARY' ÒÑÂúµÄ½â¾ö·½·¨

 1.¼ì²éÄãÊÇ·ñÏÞÖÆÁËÎļþÔö³¤:  
       ÆóÒµ¹ÜÀíÆ÷--ÓÒ¼üÄãµÄÊý¾Ý¿â--ÊôÐÔ--Êý¾ÝÎļþ--¿´¿´ÓÐûÓÐÉèÖÃÎļþµÄ×î´óÖµ  
   
   2.¼ì²éÄãµÄ´ÅÅÌ·ÖÇø¸ñʽ,Èç¹û²»ÊÇNTFS·ÖÇø,Ôò»áÓÐÏÞÖÆ,½«´ÅÅÌ·ÖÇø¸ñʽ¸Ä³ÉNTFS  
 &n ......

Êý¾Ý¿â»Ö¸´¹¤¾ß£¬Log Explorer for SQL Server v4.0

 
SQLÊý¾Ý»Ö¸´Èí¼þ Log Explorer for SQL Server v4.0
log explorerʹÓõļ¸¸öÎÊÌâ
¡¡¡¡1)¶ÔÊý¾Ý¿â×öÁËÍêÈ« ²îÒì ºÍÈÕÖ¾±¸·Ý
¡¡¡¡±¸·ÝʱѡÓÃÁËɾ³ýÊÂÎñÈÕÖ¾Öв»»î¶¯µÄÌõÄ¿
¡¡¡¡ÔÙÓÃLog explorer´òÊÔͼ¿´ÈÕ־ʱ
¡¡¡¡ÌáʾNo log recorders found that match the filter£¬would you like to view unfiltered ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ