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

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
&


Ïà¹ØÎĵµ£º

SqlServer £ºInvalid call Statement method: {0}


½ñÌì±àдÁËÒ»¸ö·ÖÒ³£¬ÔÚµ÷ÊÔÖгöÏÖÁËÈçϵĴíÎó:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid call Statement method: {0}
 at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
 at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown ......

SQLServerºÍOracle³£Óú¯Êý¶Ô±È

Êýѧº¯Êý
¡¡¡¡1.¾ø¶ÔÖµ
¡¡¡¡S:select abs(-1) value
¡¡¡¡O:select abs(-1) value from dual
¡¡¡¡2.È¡Õû(´ó)
¡¡¡¡S:select ceiling(-1.001) value
¡¡¡¡O:select ceil(-1.001) value from dual
¡¡¡¡3.È¡Õû£¨Ð¡£©
¡¡¡¡S:select floor(-1.001) value
¡¡¡¡O:select floor(-1.001) value from dual
¡¡¡¡4.È¡Õ ......

javaÊý¾Ý¿âÁ¬½Ó¼°²âÊÔ(sqlserver)


package com.test.util;
import java.sql.*;
public class ConnectDB {
 private Connection conn=null;
 private PreparedStatement pt=null;
 private ResultSet rs=null;
 private String uname="sa";
 private String upwd="sa";
 private String url="jdbc:microsoft:sqlserv ......

Sqlserver ÖÐÁÙʱ±íºÍÈ«¾ÖÁÙʱ±í

SQL Server Ö§³ÖÁÙʱ±í¡£ÁÙʱ±í¾ÍÊÇÄÇЩÃû³ÆÒÔ¾®ºÅ (#) ¿ªÍ·µÄ±í¡£Èç¹ûµ±Óû§¶Ï¿ªÁ¬½ÓʱûÓгýÈ¥ÁÙʱ±í£¬SQL Server ½«×Ô¶¯³ýÈ¥ÁÙʱ±í¡£ÁÙʱ±í²»´æ´¢ÔÚµ±Ç°Êý¾Ý¿âÄÚ£¬¶øÊÇ´æ´¢ÔÚϵͳÊý¾Ý¿â tempdb ÄÚ¡£
ÁÙʱ±íÓÐÁ½ÖÖÀàÐÍ£º 
±¾µØÁÙʱ±í 
ÒÔÒ»¸ö¾®ºÅ (#) ¿ªÍ·µÄÄÇЩ±íÃû¡£Ö»ÓÐÔÚ´´½¨±¾µØÁÙʱ±íµÄÁ¬½ÓÉϲÅÄÜ¿´ ......

ÓÃasp.net»¹Ô­Óë»Ö¸´sqlserverÊý¾Ý¿â

  
ÉÏ´Î×öÁ˸öÏîÄ¿£¬Éæ¼°µ½Êý¾Ý¿âµÄ»¹Ô­ºÍ»Ö¸´£¬µ½ÍøÉÏÕÒÁËһϣ¬ÊÇÀûÓÃSQLDMOʵÏֵģ¬Ö»ÒªÌí¼ÓSQLDMOÒýÓþͺÃÁË£¬È»ºóÀûÓÃϱߵÄÀàµÄ·½·¨¾Í¿ÉÒÔʵÏÖÁË¡£
ÎÒ°ÑÔ­×÷ÕßµÄÀàÀ©³äÁËһϣ¬¿ÉÒÔ×Ô¶¯Ê¶±ðweb.configÀï µÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬¿ÉÒÔͨ¹ý±äÁ¿ÉèÖû¹Ô­»Ö¸´µÄÐÅÏ¢¡£
ÐèҪעÒâµÄʱ»¹Ô­£¬»¹Ô­µÄʱºòÎÊÌ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ