Sql»ù±¾Óï¾äµÄѧϰ
--²éѯÿ¸öÈ˶©·¹µÄ´ÎÊý
select username as ÐÕÃû, count(*) as ´ÎÊý from orderitems group by UserName having count(*)=1
order by ÐÕÃû desc
select distinct username as δע²áÐÕÃû from orderitems
where username not in (select [Name] from Person)
select distinct username as ÒÑ×¢²áÐÕÃû from orderitems where username
in (select [Name] from Person)
--Ë÷ÒýΪ31-40µÄÊý¾Ý
select top 10 * from orderitems where ID not in (select top 30 ID from orderitems)
--¸´ÖÆÊý¾Ý
insert into distinctselect(UserName,State,OrderTime) select UserName,State,OrderTime from orderitems
--È¥³ýËùÓÐÖØ¸´µÄ¼Ç¼(ÍêÈ«ÖØ¸´)
select distinct UserName ,ID, State,OrderTime into #Table1 from [distinctselect]
delete from [distinctselect]
insert into [distinctselect](UserName,State,OrderTime) select UserName,State,OrderTime from #Table1
drop table #Table1
--ɾ³ýijÁÐÖØ¸´µÄ¼Ç¼
delete t
from [distinctselect] t
where exists (
select 1 from [distinctselect] where username=t.username and id<t.id)
select * from [distinctselect] order by username
delete from [distinctselect]
Ïà¹ØÎĵµ£º
Ó¦ÓÃIDS·ÀÖ¹SQL×¢Èë¹¥»÷
http://www.cnhacker.com/Hacker/Skills/200807/t20080731_6187.html
Ŀǰ£¬Õë¶ÔÓ¦Óü°Æäºǫ́Êý¾Ý¿âµÄÓ¦Óü¶ÈëÇÖÒѾ±äµÃÔ½À´Ô½²þâ±£¬ÈçSQL×¢Èë¡¢¿çÕ¾µã½Å±¾¹¥»÷ºÍδ¾ÊÚȨµÄÓû§·ÃÎʵȡ£ËùÓÐÕâЩÈëÇÖ¶¼ÓпÉÄÜÈÆ¹ýǰ̨°²È«ÏµÍ³²¢¶ÔÊý¾ÝÀ´Ô´·¢Æð¹¥»÷¡£
ΪÁ˶Ը¶ÕâÀàÍþв£¬ÐÂÒ»¼¶±ðµÄ°²È«ÍÑÓ±¶ø³ö£ ......
Èí¼þ £º Sql Server 2005
ÕâÀï²¢²»ÊÇSQLÓï·¨´óÈ«£¬ÒÔÏÂÊdz£ÓõÄÓï¾ä£¬¶Ô£¨Êý¾Ý¿â¡¢±í¡¢×ֶΡ¢Êý¾Ý£©µÄÔöɾ¸Ä²é£¬Èç¹ûÐèÒªÏêÏ¸È«ÃæµÄTransact-SQLÓï¾ä£¬¿ÉÒÔ²éSql ServerÁª»ú´ÔÊ飬ÄÇÀïÊÇ×îÈ«µÄ×ÊÁÏ£¬Ò»°ã°²×°Sql Server¶¼»áĬÈϰ²×°¡£
´ò¿ªSql ServerÁª»ú´ÔÊé
¿ªÊ¼ à ³ÌÐò à&n ......
ÒÔÏÂÊÇÒ»¸ö²éѯIPµØÖ·¹éÊôµØµÄCLR´æ´¢¹ý³Ì£¬Èý²½£º
1¡¢ÓÃC#À´×öDLL£¬´úÂëÈçÏ£º
//====================================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.Sq ......
ÓÐʱ¼ä°²×°ÁËsql server Ö®ºóûÓзþÎñµÄÇé¿ö£¬²»ÓÃÐ¶ÔØ²»ÓÃ֨װ£¬Äã°Ñ SQL EXPRESS ÔÙ¸²¸Ç×°Ò»±ß¾Í¿ÉÒÔÁË£¬Õâ¸ö·þÎñÊÇ´ÓÕâ¸ö×é¼þÀïÃæÌṩµÄ¡£
ÏÂÔØµØÖ·£ºhttp://www.microsoft.com/downloadS/details.aspx?familyid=220549B5-0B07-4448-8848-DCC397514B41&displaylang=zh-cn ......
ÕâÊÇÒ»¸ö²»´íµÄÀý×Ó£¬ÌØ×ªÔØ·ÖÏíÖ®¡£
------------±íÖеÄ×Ö¶Î---------------
CREATE TABLE [dbo].[stuInfo] (
[FNumber] [int] IDENTITY(1,1) NOT NULL ,
[FName] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[FNameen] [varchar] (35) COLLATE Chinese_PRC_CI_AS ,
[FSex] [char] (1) COLLATE C ......