SQLº¯Êý:ÊÂÎñʵÀý
ΰÉÙÌìµØ
ÊÂÎñ¾ÍÊǸºÔð°ÑһϵÁвÙ×÷¿´×öÒ»¸ö¶ÀÁ¢µÄÂß¼µ¥Ôª£¬ÕâЩ²Ù×÷Ҫôͬʱ³É¹¦£¬ÒªÃ´Í¬Ê±Ê§°Ü¡£ÏÂÃæÊÇÒ»¸ö¾µäµÄÀý×Ó£º
create procedure TransferMoeny
(
@fromAccountNo varchar(50),-- ת³öÕ˺Å
@ToAccountNo varchar(50),--תÈëÕ˺Å
@MoneyCount money--תÕ˽ð¶î
)
as
--ÅжÏÕ˺ÅÊÇ·ñ´æÔÚ
if exists (select 1 from ÕÊ»§±í where Õ˺Š= @fromAccountNo)
begin
if exists (select 1 from ÕÊ»§±í where Õ˺Š= @ToAccountNo)
begin
--ÅжÏת³ö½ð¶îÊÇ·ñ´óÓÚµ±Ç°Óà¶î
if (select µ±Ç°Óà¶î from ÕÊ»§±í where Õ˺Š= @fromAccountNo) >= @MoneyCount
begin
--¿ªÊ¼×ªÕË
begin transaction
insert into [´æÈ¡¼Ç¼±í] ([Õ˺Å],[´æÈ¡ÀàÐÍ], [´æÈ¡½ð¶î]) values(@fromAccountNo, -1,@MoneyCount)
if @@error <> 0
begin
rollback transaction--·¢Éú´íÎóÔò»Ø¹öÊÂÎñ£¬ÎÞÌõ¼þÍ˳öl
return
end
&nbs
Ïà¹ØÎĵµ£º
Join²Ù×÷·û
ÊÊÓó¡¾°£ºÔÚÎÒÃDZí¹ØϵÖÐÓÐÒ»¶ÔÒ»¹Øϵ£¬Ò»¶Ô¶à¹Øϵ£¬¶à¶Ô¶à¹ØϵµÈ¡£¶Ô¸÷¸ö±íÖ®¼äµÄ¹Øϵ£¬¾ÍÓÃÕâЩʵÏÖ¶Ô¶à¸ö±íµÄ²Ù×÷¡£
˵Ã÷£ºÔÚJoin²Ù×÷ÖУ¬·Ö±ðΪJoin(Join²éѯ), SelectMany(SelectÒ»¶Ô¶àÑ¡Ôñ)ºÍGroupJoin(·Ö×éJoin²éѯ)¡£
¸ÃÀ©Õ¹·½·¨¶ÔÁ½¸öÐòÁÐÖмüÆ¥ÅäµÄÔªËؽøÐÐinner join²Ù×÷
SelectMany
˵Ã÷£ºÎÒà ......
°¥£¬»¹ÊÇÉÏÖܵÄÊÂÇéÁË£¬csdnµÄ²©¿Í×î½üÕ¦ÀÏÊÇ´ò²»¿ªÄØ£¡
»ù±¾Óï¾ä£ºAlter table ±íÃû drop Column ×Ö¶ÎÃû
Áíµ¥µ¥ÊÇÕâÑùÊDz»ÐеΣ¬»¹ÒªÉ¾³ý¶ÔÓ¦µÄ¹ØϵµÎ¡£ÏÂÃæ¾Í°Ñ²éÕÒµ½µÄÄÇƪÎÄÕÂÒýÓÃÏ°ɣ¡
ÔÎĵØÖ·£ºhttp://hi.baidu.com/lisky119/blog/item/3c348c082573949c0a7b82d1.html
SET ANSI_NULLS ON
GO
SET QUOTED_IDENT ......
ÎÒÃÇͨ³£ÔÚ¶¨Î»Êý¾Ý¿âËøÎÊÌâʱ£¬Í¨³£Ï£ÍûÕÒµ½Äĸö½ø³Ì·¢³öÁËÄĸöÓï¾ä£¬ËøסÁËÄÄÕÅ±í£¬Ò»°ãÎÒÃÇͨ¹ý²év$lock£¬È»ºóÕÒµ½sid,ÔÙµ½v$sesionÀïÕÒµ½Õâ¸ö½ø³ÌµÄhash_value»òpre_hash_value,È»ºó¸ù¾Ýhash_value¶¨Î»µ½¾ßÌåµÄÓï¾ä¡£
¿ÉÊÇ£¬ÎÒÃÇ·¢ÏÖ£¬Í¨¹ýJDBCÁ¬½ÓÉÏÀ´µÄ½ø³Ì£¬ËüµÄhash_valueÊÇ0,ËùÒÔÎÒÃǾÍÎÞ·¨¶¨Î»Õâ¸ö½ø³ÌÖ´ÐеÄÓï¾ ......
sql server 2000µ¼³ö±í½á¹¹
1.
SELECT
±íÃû=case when a.colorder=1 then d.name else '' end,
±í˵Ã÷=case when a.colorder=1 then isnull(f.value,'') else '' end,
×Ö¶ÎÐòºÅ=a.colorder,
×Ö¶ÎÃû=a.name,
±êʶ=case when COLUMNPROPERTY( a.id, ......