SQLSERVER¼òµ¥´¥·¢Æ÷
INSERT´¥·¢Æ÷
INSERT¼°UPDATE´¥·¢Æ÷¾³£ÓÃÓÚ¼ì²â´¥·¢Æ÷Ëù¼à¿Ø±íµÄÁм°ÆäÊý¾ÝÊÇ·ñ·ûºÏËù¶¨ÒåµÄ¹æÔò¡£ËüÃÇ¿ÉÒÔÔÚÊý¾ÝÊäÈë±í֮ǰ£¬¶ÔÆä½øÐÐÔÚ¶¨ÒåÒýÓÃÍêÕûÐÔʱÎÞ·¨Íê³ÉµÄÔ¼Êø¼ìÑé¡£
ÏÂÃæÒÔѧÉúÊý¾Ý¿âstudentΪÀýÀ´½éÉÜINSERT´¥·¢Æ÷µÄʹÓ᣸ÃÊý¾Ý¿â°üÀ¨Èý¸ö±í£¬·Ö±ðÊÇÃèÊöѧÉúÇé¿öµÄ“ѧÉúµµ°¸”±í¡¢ÃèÊöѧÉú³É¼¨µÄ“ѧÉú³É¼¨”±ístudentºÍ¡£ÃèÊö·Ö×éÇé¿öµÄ“·Ö×éÇé¿ö”±ígro¡£
create table student (id numeric(1,0),name varchar(10),sex char(4),class varchar(10),gro numeric(1,0) )
create table gro (class varchar(10),gro numeric(1,0) ,num tinyint)
ΪÉÏÃæµÄ“ѧÉúµµ°¸” ±í´´½¨Ò»¸öINSERT´¥·¢Æ÷instrg£¬Æä×÷ÓÃÊÇÿÐÂÔöÒ»ÃûѧÉú¶øÐèÏò“ѧÉúµµ°¸”±íÖвåÈëÐÂÐÐʱ£¬ÔÚ“·Ö×éÇé¿ö”±íÖн«ÆäËùÔÚС×éµÄÈËÊý×Ô¶¯Ôö¼Ó1¡£
use mlh
Create Trigger instrg ON [dbo].[student]
FOR Insert
AS
declare @°à¼¶ varchar(50) ,@С×é varchar(50),@ÈËÊý tinyint
select @°à¼¶ = inserted.class,@С×é = inserted.gro from inserted
if exists(select num from gro where @°à¼¶ = gro.class and @С×é= gro.gro)
begin --bg1
select @ÈËÊý = num from gro where @°à¼¶= gro.class and @С×é = gro.gro
set @ÈËÊý = @ÈËÊý + 1
update gro set num = @ÈËÊý where @°à¼¶ = gro.class and @С×é = gro.gro
end --bg1
else
begin --bg2
insert gro values(@°à¼¶,@С×é,1)
end --bg2
UPDATE ´¥·¢Æ÷
Create Trigger stup On [dbo].[student]
FOR update
AS
Declare @°à¼¶ varchar(50) , @С×é numeric(1,0),@ÈËÊý tinyint
select @°à¼¶ = inserted.class ,@С×é= inserted.gro from inserted
if exists(select * from gro where @°à¼¶ = gro.class and @С×é = gro.gro)
begin
update gro set gro.num = gro.num + 1 where @°à¼¶ = gro.class and @С×é = gro.gro
end
else
begin
insert into gro values(@°à¼¶,@С×é,1)
end
select @°à¼¶ = deleted.class ,@С×é= deleted.gro from deleted
select @ÈËÊý = gro.num from gro where @°à¼¶ = gro.class and @С×é = gro.gro
if @ÈËÊý > 1
begin
&
Ïà¹ØÎĵµ£º
ÔÚÊý¾Ý¿â±à³ÌÖУ¬³£»áÓöµ½Òª°ÑÊý¾Ý¿â±íÐÅÏ¢µ¼ÈëExcelÖУ¬ ÓÐʱÔòÊÇ°ÑExcelÄÚÈݵ¼ÈëÊý¾Ý¿âÖС£ÔÚÕâÀ½«½éÉÜÒ»ÖֱȽϷ½±ã¿ì½ÝµÄ·½Ê½£¬Ò²ÊDZȽÏÆÕ±éµÄ¡£Æäʵ£¬Õâ·½·¨Äã²¢²»Ä°Éú¡£ÔÀíºÜ¼òµ¥£¬°ÑÊý¾Ý¿â±í»òExcelÄÚÈݶÁÈ¡µ½datasetÀàÐ͵ıäÁ¿ÖУ¬ÔÙÖð ......
SERVER Í£Ö¹,ÎÞ·¨Æô¶¯,¹ýÆÚÁË (ÆÀ¹À°æ2000)(2008-04-25 22:31:17)±êÇ©£ºsql server ÎÞ·¨Æô¶¯ ¹ýÆÚ ½â¾ö·½·¨ it
µ± SQL Server 2000 ÆÀ¹À°æµÄ 120 ÌìÆÀ¹ÀÆÚ¹ýÆÚºó£¬SQL Server ½«ÎÞ·¨Æô¶¯¡£
ÔÚ Windows ʼþ²é¿´Æ÷Ó¦ÓóÌÐòÈÕÖ¾ÖУ¬Äú¿ÉÄܻῴµ½ÏÂÃæµÄ´íÎó£º
SQL Server evaluation period has expired ......
ͨÅä·û ˵Ã÷
_ ÓëÈÎÒâµ¥×Ö·ûÆ¥Åä
% Óë°üº¬Ò»¸ö»ò¶à¸ö×Ö·ûµÄ×Ö·û´®Æ¥Åä
[ ] ÓëÌض¨·¶Î§£¨ÀýÈ磬[a-f]£©»òÌض¨¼¯£¨ÀýÈ磬[abcdef]£©ÖеÄÈÎÒâµ¥×Ö·ûÆ¥Åä¡£
[^] ÓëÌض¨·¶Î§£¨ÀýÈ磬[^a-f]£©»òÌض¨¼¯£¨ÀýÈ磬[^abcdef]£©Ö®ÍâµÄÈÎÒâµ¥×Ö·ûÆ¥Åä¡£
......
½ñÌìÔÚ¸ø¹«Ë¾×öÍøվʱ£¬Ö÷¹Ü¸øÁËÒ»¸öеÄÐèÇó¸øÎÒ£¬ÓÉÓÚ¹«Ë¾µÄµç»°±íÊý¾Ý±È½Ï¶à£¬ÐèÒªµ¼Èëµ½Êý¾Ý¿â±íÖУ¬ËùÒÔÌØÒâµÄ´ÓÍøÉϲéÔÄÁËһЩ×ÊÁÏ£¬¼òÒ×µÄдÁ˸ö´ÖÂÔµÄÀ࣬»ù±¾ÔÀíÊÇ£º°ÑExcel×öΪÊý¾ÝÔ´£¬ÐγÉdatable¶ÔÏó£¬ È»ºóÔÚÊý¾Ý¿â½¨Á¢Ò»ÕűíÒ»ÁÐÒ»ÁеĽ«Êý¾ÝÌí¼Óµ½Ð±íÖУ¬ÊµÏÖµÄÀࣺ
using System;
using S ......
ÉÏ´Î×öÁ˸öÏîÄ¿£¬Éæ¼°µ½Êý¾Ý¿âµÄ»¹ÔºÍ»Ö¸´£¬µ½ÍøÉÏÕÒÁËһϣ¬ÊÇÀûÓÃSQLDMOʵÏֵģ¬Ö»ÒªÌí¼ÓSQLDMOÒýÓþͺÃÁË£¬È»ºóÀûÓÃϱߵÄÀàµÄ·½·¨¾Í¿ÉÒÔʵÏÖÁË¡£
ÎÒ°ÑÔ×÷ÕßµÄÀàÀ©³äÁËһϣ¬¿ÉÒÔ×Ô¶¯Ê¶±ðweb.configÀï µÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬¿ÉÒÔͨ¹ý±äÁ¿ÉèÖû¹Ô»Ö¸´µÄÐÅÏ¢¡£
ÐèҪעÒâµÄʱ»¹Ô£¬»¹ÔµÄʱºòÎÊÌ ......