CREATE TRIGGER tongji ON [dbo].[user] 
FOR INSERT, UPDATE, DELETE 
AS
declare @num int ;
select count(*) into @num from [user] where username='zhang'
在sqlserver2000下count后的数值  这样做对吗  ?应该怎么做?

解决方案 »

  1.   

    CREATE TRIGGER tongji ON [dbo].[user] 
    FOR INSERT, UPDATE, DELETE 
    AS 
    declare @num int ; 
    select @num = count(*) from [user] where username='zhang' 
      

  2.   

    你這個是Oracle的寫法呀.CREATE TRIGGER tongji 
    ON [dbo].[user] 
    FOR INSERT, UPDATE, DELETE 
    AS select count(*) from deleted where username='zhang' 
      

  3.   

    刚刚学  看一本电子书  也没说是sql server 还是 orale 弄得现在很糊涂啊
      

  4.   

    兩者的語法有區別的.建議你還是看專門介紹SQL的書.
    要不然,你會被搞混了.
      

  5.   


    CREATE TRIGGER tongji ON [dbo].[user] 
    FOR INSERT, UPDATE, DELETE 
    AS 
    declare @num int ; 
    select @num = count(*) from [user] where username='zhang' 
      

  6.   


    CREATE TRIGGER tongji ON [dbo].[user] 
    FOR INSERT, UPDATE, DELETE 
    AS 
    declare @num int ; 
    select @num=count(*)from [user] where username='zhang' 
    这样才是给变量赋值呀!!
      

  7.   

    给变量赋值不能那么用 INTO 就到临时表里去了。
    select @num = count(*) from [user] where username='zhang'