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

sql ²éѯÏȽøÏȳö

declare @tb3 table (ÉÌÆ·±àºÅ nvarchar(10),Åú´ÎºÅ nvarchar(10),¿â´æÊýÁ¿ int,³ö¿âÊýÁ¿ int)
declare @tb1 table (ÉÌÆ·±àºÅ nvarchar(10),Åú´ÎºÅ nvarchar(10),¿â´æÊýÁ¿ int)
insert into @tb1 select '0001','090801',200
      union all  select '0001','090501',50
      union all  select '0002','090101',30
      union all  select '0002','090701',200
declare @tb2 table (ÉÌÆ·±àºÅ nvarchar(10),¶©»õÊýÁ¿ int)
insert into @tb2 select '0001',60
      union all  select '0002',20
--declare @var int
declare c_sor cursor
for
select ÉÌÆ·±àºÅ,sum(¶©»õÊýÁ¿)¶©»õÊýÁ¿ from @tb2 group by ÉÌÆ·±àºÅ
declare @bh nvarchar(10), @dh int,@bh1 nvarchar(10),@pc nvarchar(10), @kc int
open  c_sor
fetch next from c_sor into @bh,@dh
while @@fetch_status=0
begin
declare sor cursor for select * from @tb1 where ÉÌÆ·±àºÅ=@bh order by Åú´ÎºÅ
open sor
fetch next from sor into @bh1,@pc,@kc
insert into @tb3 select @bh, @pc,@kc,case when @kc>@dh then @dh else @kc end
set @dh=@dh-@kc
while @dh>0
 begin
 fetch next from sor into @bh1,@pc,@kc
 insert into @tb3 select @bh, @pc,@kc,case when @kc>=@dh then @dh else @kc end
 set @dh=@dh-@kc
 end
close sor
deallocate sor
fetch next from c_sor into @bh,@dh
end
close c_sor
deallocate c_sor
select * from @tb3  order by ÉÌÆ·±àºÅ,Åú´ÎºÅ desc


Ïà¹ØÎĵµ£º

ASP.NET·ÀSQL×¢Èë½Å±¾³ÌÐò v2.0

public class SqlCheck
{
public SqlCheck()
{
//
// TODO: ÔÚ´Ë´¦Ìí¼Ó¹¹Ô캯ÊýÂß¼­
//
}

public SqlConnection oconn()
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["StudyConnectionString"] ......

SQLɾ³ýÖ¸¶¨×Ö¶ÎÎÊÌâ

¸üÐÂÏÂÎÊÌ⣺
񡜧TBL_Info
×ֶΣº
    infoId int
    title  varchar(20)
    Content  text
    byUser  varchar(20)
    createTime datetime
1¡¢ÈçºÎɾ³ý±íÖÐÊý¾ÝÏàͬµÄÊý¾ÝÄØ£¿£¨Ö÷¼ü³ýÍ⣩
2¡¢ÈçºÎɾ³ýÊý¾Ý±íÖÐij¸ö×Ö¶ÎÊý¾ÝÏàÍ ......

SQL Server 2005 ĬÈÏsaÎÞ·¨µÇ½

ʹÓÃSQL ServerÉí·ÝÑéÖ¤µÇ¼ʱ±¨´í£º
ÎÞ·¨Á¬½Óµ½.\SQLEXPRESS.
Additional information:
Óû§'sa'µÇ¼ʧ°Ü¡£¸ÃÓû§Óë¿ÉÐÅSQL Server Á¬½ÓÎÞ¹ØÁª¡£(microsoft SQL Server,Error:18452£©)
------------------
ÏÂÃæÊÇÓ³Éäʱ±¨µÄ´í£º
´´½¨¶ÔÓÚÓû§“sa”ʧ°Ü¡££¨microsoft.sqlServer.express.smo£©
Additional ......

°²×°SQL 2000¹ÒÆðµÄ½â¾ö°ì·¨

½ñÌì°²×°sql2000£¬ÀÏÊdzö¹ÒÆðµÄ´íÎó¡£ËùÒÔÕÒÁËÕÒ¿´¼ûÁËÕâ¸ö·½·¨¡£
Ô­ÌûµØÖ·£ºhttp://hi.baidu.com/xpyi/blog/item/fa1fd3af254d32f2fbed500d.html
²½ÖèÊÇ£º
1£©Ìí¼Ó/ɾ³ý³ÌÐòÖг¹µ×ɾ³ýsql server¡£
2£©½«Ã»ÓÐɾ³ýµÄsql serverĿ¼Ҳɾ³ýµô¡£
3£©´ò¿ª×¢²á±í±à¼­Æ÷£¬ÔÚHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ ......

sql×¢Èë

Ê×ÏÈÎÒÏëлл԰×ÓµÄÅóÓÑÃÇ£¬ÊÇÄãÃÇÌáÐÑÎÒдÄÚÈÝÓдíÎ󣬼ǵÃÔø¾­µç×ÓÉÌÎñÖ®Êý¾Ý´æ´¢Á÷³Ì£¨Î壩ÀïÃæ˵µ½“Ñ¡´æ´¢¹ý³Ì+´«µÝ²ÎÊýÓÃSqlParameterÊÇÒòΪ£¬³ý·ÇÊÇADO.NETÓЩ¶´£¬ÄÇô¾Í¾ø¶Ô²»»á·¢ÉúSQL×¢È딡£Keep Walking´ó¸çÒ²ÔÚ¹ØÓÚ·ÀÖ¹sql×¢ÈëµÄ¼¸ÖÖÊֶΣ¨¶þ£©ÖоٳöÀ´Ò»¸öÀý×Ó˵Ã÷ÎÒ˵µÄÉϾ仰ÊÇ´íÎóµÄ¡£ËµÊµ»°µ± ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ