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

SQL SERVERÁÙʱ±íµÄʹÓÃ


drop table #Tmp   --ɾ³ýÁÙʱ±í#Tmp
create table #Tmp --´´½¨ÁÙʱ±í#Tmp
(
    ID   int IDENTITY (1,1)     not null, --´´½¨ÁÐID,²¢ÇÒÿ´ÎÐÂÔöÒ»Ìõ¼Ç¼¾Í»á¼Ó1
    WokNo                varchar(50),  
    primary key (ID)      --¶¨ÒåIDΪÁÙʱ±í#TmpµÄÖ÷¼ü     
);
Select * from #Tmp    --²éѯÁÙʱ±íµÄÊý¾Ý
truncate table #Tmp --Çå¿ÕÁÙʱ±íµÄËùÓÐÊý¾ÝºÍÔ¼Êø
Ïà¹ØÀý×Ó£º
Declare @Wokno Varchar(500) --ÓÃÀ´¼Ç¼ְ¹¤ºÅ
Declare @Str NVarchar(4000) --ÓÃÀ´´æ·Å²éѯÓï¾ä
Declare @Count int --Çó³ö×ܼǼÊý     
Declare @i int
Set @i = 0
Select @Count = Count(Distinct(Wokno)) from #Tmp
While @i < @Count
    Begin
       Set @Str = 'Select top 1 @Wokno = WokNo from #Tmp Where id not in (Select top ' + Str(@i) + 'id from #Tmp)'
       Exec Sp_ExecuteSql @Str,N'@WokNo Varchar(500) OutPut',@WokNo Output
       Select @WokNo,@i --Ò»ÐÐÒ»ÐаÑÖ°¹¤ºÅÏÔʾ³öÀ´
       Set @i = @i + 1
    End
ÁÙʱ±í
¿ÉÒÔ´´½¨±¾µØºÍÈ«¾ÖÁÙʱ±í¡£±¾µØÁÙʱ±í½öÔÚµ±Ç°»á»°Öпɼû£»È«¾ÖÁÙʱ±íÔÚËùÓлỰÖж¼¿É¼û¡£
±¾µØÁÙʱ±íµÄÃû³ÆÇ°ÃæÓÐÒ»¸ö±àºÅ·û (#table_name)£¬¶øÈ«¾ÖÁÙʱ±íµÄÃû³ÆÇ°ÃæÓÐÁ½¸ö±àºÅ·û (##table_name)¡£
SQL Óï¾äʹÓà CREATE TABLE Óï¾äÖÐΪ table_name Ö¸¶¨µÄÃû³ÆÒýÓÃÁÙʱ±í£º
CREATE TABLE #MyTempTable (cola INT PRIMARY KEY)
INSERT INTO #MyTempTable VALUES (1)
Èç¹û±¾µØÁÙʱ±íÓÉ´æ´¢¹ý³Ì´´½¨»òÓɶà¸öÓû§Í¬Ê±Ö´ÐеÄÓ¦ÓóÌÐò´´½¨£¬Ôò SQL Server ±ØÐëÄܹ»Çø·ÖÓɲ»Í¬Óû§´´½¨µÄ±í¡£Îª´Ë£¬SQL Server ÔÚÄÚ²¿ÎªÃ¿¸ö±¾µØÁÙʱ±íµÄ±íÃû×·¼ÓÒ»¸öÊý×Öºó׺¡£´æ´¢ÔÚ tempdb Êý¾Ý¿âµÄ sysobjects ±íÖеÄÁÙʱ±í£¬ÆäÈ«ÃûÓÉ CREATE TABLE Óï¾äÖÐÖ¸¶¨µÄ±íÃûºÍϵͳÉú³ÉµÄÊý×Öºó׺×é³É¡£ÎªÁËÔÊÐí×·¼Óºó׺£¬Îª±¾µØÁÙʱ±íÖ¸¶¨µÄ±íÃû table_name ²»Äܳ


Ïà¹ØÎĵµ£º

SQL²éѯ·ÖÎöÆ÷Íâ¹ÒÔ´Âë·ÖÏí

±¾ÈËдÁËÒ»¸öSQL²éѯ·ÖÎöÆ÷À©Õ¹¹¤¾ß£¬¹¦ÄÜÀàËÆDelphiµÄToDo¡£¿ÉÒÔ·½±ã¿ª·¢ÕßÔÚ´óÁ¿µÄSQL½Å±¾ÖпìËÙÕÒµ½Ã¿¸öÄ£¿é¡¢To-Do£¬´Ó¶øÌá¸ß¿ª·¢¸ßÀûÂÊ¡£
ʹÓõÄʱºòÏÈÔËÐÐSQL²éѯ·ÖÎöÆ÷£¬È»ºóÔËÐб¾³ÌÐò¼´¿É£¨¿ÉÒÔ¹¤¾ß|×Ô¶¨ÒåÖÐÅäÖã©¡£°´F2ÏÔʾTo-Do List´°¿Ú£¬°´Alt+F2ÔÚµ±Ç°Î»ÖòåÈëTo-Do¡£
ÓÉÓÚʱ¼ä¹Øϵ£¬±¾³ÌÐò²¢Î´ÍêÉÆ£¬ÔÚË« ......

SQL*PLUSÃüÁîµÄʹÓôóÈ«(ת)

תÔصØÖ·£ºhttp://langdorf.blog.163.com/blog/static/131177212200992981939316/
 
OracleµÄsql*plusÊÇÓëoracle½øÐн»»¥µÄ¿Í»§¶Ë¹¤¾ß¡£ÔÚsql*plusÖУ¬¿ÉÒÔÔËÐÐsql*plusÃüÁîÓësqlÓï¾ä¡£
ÎÒÃÇͨ³£Ëù˵µÄDML¡¢DDL¡¢DCLÓï¾ä¶¼ÊÇsqlÓï¾ä£¬ËüÃÇÖ´ÐÐÍêºó£¬¶¼¿ÉÒÔ±£´æÔÚÒ»¸ö±»³ÆΪsql bufferµÄÄÚ´æÇøÓòÖУ¬²¢ÇÒÖ»Äܱ£´æÒ»Ì ......

[SQL Server2008]SQL Server ÖÐ.Óë::µÄÇø±ð(ת)

SQL ServerÖе÷Ó÷½·¨Ê±£¬¾­³£Óöµ½.»òÊÇ::Á½ÖÖµ÷Ó÷½·¨£¬ÆäÖÐ. ÊÇʵÀýµ÷Ó÷½·¨£¬::ÊǾ²Ì¬µ÷Ó÷½·¨¡£Èç¹û´ó¼Ò¶ÔC#Óï·¨ÊìϤµÄ»°£¬. ¶ÔÓ¦C#Öе÷ÓÃʵÀý·½·¨£¬:: ¶ÔÓ¦C#ÖеÄstatic·½·¨¡£
ÏÂÃæ¸ø³öÒ»¸öSQL ServerµÄʵÀý£¬ÏÂÃæµÄSQLÔËÐÐÔÚ2008»·¾³Ï£º
DECLARE @g geography;
SET @g = geography::Parse('LINESTRING(-122.360 ......

sqlËø»úÖÆ´óÈ«

ËøµÄ¸ÅÊö ¡¡¡¡Ò». ΪʲôҪÒýÈëËø
¡¡¡¡¶à¸öÓû§Í¬Ê±¶ÔÊý¾Ý¿âµÄ²¢·¢²Ù×÷ʱ»á´øÀ´ÒÔÏÂÊý¾Ý²»Ò»ÖµÄÎÊÌ⣺
¡¡¡¡¶ªÊ§¸üÐÂ
¡¡¡¡A£¬BÁ½¸öÓû§¶ÁͬһÊý¾Ý²¢½øÐÐÐ޸ģ¬ÆäÖÐÒ»¸öÓû§µÄÐ޸Ľá¹ûÆÆ»µÁËÁíÒ»¸öÐ޸ĵĽá¹û£¬±ÈÈ綩Ʊϵͳ
¡¡¡¡Ôà¶Á
¡¡¡¡AÓû§ÐÞ¸ÄÁËÊý¾Ý£¬ËæºóBÓû§ÓÖ¶Á³ö¸ÃÊý¾Ý£¬µ«AÓû§ÒòΪijЩԭÒòÈ¡ÏûÁ˶ÔÊý¾ ......

SQL·±體²é詢ÖÐÌØ別×÷¹ÖµÄµØ·½

½ñÌ칤×÷時ºò輸Èë數據庫ÖÐÓÐÒ»條數據×Ö¶Î記錄ÊÇ"¿Í戶·ñ¾ö"
ʹÓÃ
select * from TelephoneStatusCategory where  CategoryName like '%¿Í戶·ñ%'
select * from TelephoneStatusCategory where  CategoryName like '%¿Í戶·ñ¾ö% ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ