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

ɾ³ýÖØ¸´Êý¾ÝµÄsql·½·¨

±íÖÐÓÐһЩ¼Ç¼ÄÚÈÝÖØ¸´£¬Ò²¾ÍÊÇ˵ÕâЩ¼Ç¼³ýÁËID²»Í¬Ö®Í⣬ÆäËûµÄÐÅÏ¢¶¼Ïàͬ¡£ÐèÒª°ÑÖØ¸´µÄ¼Ç¼±£ÁôÒ»Ìõ£¬Ê£ÏµÄɾ³ý
--µÚÒ»ÖÖ·½·¨
delete from temp where id not IN (select min(id) from temp group by col1,col2)
--¶Ôcol1,col2£¬¼´ÒªÉ¾³ýµÄÊý¾Ýcol1,col2Á½¸öÁж¼Ïàͬ,ɾ³ýid´óµÄÐÐ
--µÚ¶þÖÖ·½·¨
with a as
(select row_number() over (partition by col1,col2 order by col1,col2) as rid,* from temp
)
delete a where rid>1
--partition by col1,col2 ×÷ÓÃÈçgroup by col1,col2,¼´ÒªÉ¾³ýµÄÐÐcol1,col2Á½¸öÁеÄÊý¾ÝÏàͬ£¬É¾³ýid´óµÄÐÐ


Ïà¹ØÎĵµ£º

SQL²éѯÓÅ»¯

»ùÓÚË÷ÒýµÄSQLÓï¾äÓÅ»¯Ö®½µÁúÊ®°ËÕÆ
1         ǰÑÔ
¿Í·þÒµÎñÊܵ½SQLÓï¾äµÄÓ°Ïì·Ç³£´ó£¬ÔÚ¹æÄ£±È½Ï´óµÄ¾Öµã£¬ÍùÍùÒòΪһ¸öСµÄSQLÓï¾ä²»¹»ÓÅ»¯£¬µ¼ÖÂÊý¾Ý¿âÐÔÄܼ±¾çϽµ£¬Ð¡ÐÍ»úidleËùÊ£ÎÞ¼¸£¬Ó¦Ó÷þÎñÆ÷¶ÏÁ¬¡¢³¬Ê±£¬ÑÏÖØÓ°ÏìÒµÎñµÄÕý³£ÔËÐС£Òò´Ë£¬³ÆµÍЧµÄSQLÓï¾äΪ¿Í·þÒµÎñµÄ ......

vs2005ÖÐÎÞ·¨Á¬½ÓSQLÎÊÌ⣨ת£©

vs2005ÖÐÎÞ·¨Á¬½ÓSQLÎÊÌâ
×î½üÔÚÑо¿ASP.NET£¬ÔÚ°²×°VS2005ºÍSQLÉÏ£¬ÎÊÌâ¶à¶à°¡£¬¿¨ÁËÎҺܶàÌ죬×îºóÔÚ²éÔÄÒ»¶Ñ×ÊÁϺÍ֨װÎÞÊý´Îϵͳ֮ºó£¬ÖÕÓÚÑо¿³öΪʲôÎÒ²»ÄÜÁ¬½ÓÊý¾Ý¿âµÄÎÊÌâÁË£¬½â¾ö·½·¨ÈçÏ£º
¡¡¡¡(1)¿ªÊ¼->³ÌÐò->Microsoft SQL Server 2005->SQL Server 2005ÍâΧӦÓÃÅäÖÃÆ÷,ÔÚ´ò¿ªµÄ½çÃæµ¥»÷"·þÎñµÄÁ¬ ......

SQL ServerÖеÄT SQLµÄ»ù±¾¶ÔÏó


    SQLµÄ»ù±¾¶ÔÏóÖ÷ÒªÓг£Á¿£¬±íʾ·û£¬·Ö¸ô·û£¬±£Áô¹Ø¼ü×Ö¡£
 1¡¢³£Á¿
 ³£Á¿ÊÇÒ»¸ö°üº¬ÎÄ×ÖÓëÊý×Ö£¬Ê®Áù½øÖÆ»òÊý×Ö³£Á¿¡£Ò»¸ö×Ö·û´®³£Á¿°üº¬µ¥ÒýºÅ('')»òË«ÒýºÅ("")×Ö·û¼¯ÖеÄÒ»¸ö»ò¶à¸ö×Ö·û¡£
 Èç¹ûÏëÔÚµ¥ÒýºÅ·Ö¸ôµÄ×Ö·û´®ÖÐÓõ½µ¥¶ÀµÄÒýºÅ£¬¿ÉÒÔÔÚÕâ¸ö×Ö·ûÖÐÓû§Á¬ÐøµÄµ¥ÒýºÅ£¨¼´ÓÃÁ ......

SQL SERVER£ºselect ×Ö·û´®Æ´½ÓÎÊÌâ

Ò»¡¢ÎÊÌâ
select UserID,LastName,FirstName,UserName from SYSUser
UserID LastName FirstName UserName
------------------------------------------------------
1      A        B        C
2  &nb ......

ÖµµÃÊղصÄMicrosoft SQL ServerϵÄSQLÓï¾ä

SQLÓï¾äÏÈǰдµÄʱºò£¬ºÜÈÝÒ×°ÑÒ»Ð©ÌØÊâµÄÓ÷¨Íü¼Ç£¬ÎÒÌØ´ËÕûÀíÁËÒ»ÏÂSQLÓï¾ä²Ù×÷¡£
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssq ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ