Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 systemDate

Author  Topic 

adnanans78
Starting Member

17 Posts

Posted - 2007-08-27 : 12:43:12
Hi,

I m useing trigger on table.I get modification in the table by inserted virtual table.but when i try to store it in seperate table with addition more values to other attributes I give an error.Syntex is below

create trigger test on test
for insert,update,delete
as
begin

insert chnages (getDate(),user_name(),select *from inserted)
end

it is not working rightly.
any one help.

thnx in advance

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-27 : 13:02:45
Insert changes (sysdate, <other columnS> )
select getdate(), *from inserted



Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-27 : 13:03:01
Basically, you need to list out the column names.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-27 : 13:03:45
insert chnages (column list in correct order here )
select getDate(),user_name(), otherColumnsInCorrectOrderHere
from inserted

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-27 : 13:04:03


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

adnanans78
Starting Member

17 Posts

Posted - 2007-08-28 : 00:59:15
hi,
Thnx for replies.how i can get current table which is modified and which trigger is fired?I set up some triggers on few tables.On the basis of trigger i will get data from the virtual tables.
thnx in advance

Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-08-28 : 22:15:01
You can find sample trigger code in books online.
Go to Top of Page

adnanans78
Starting Member

17 Posts

Posted - 2007-08-29 : 08:33:21
Hi,
Thanx for reply,
Is it possible that records can be inserted in to a table which contain collumns 20 from another table contain collumns 10.remaining collumn set value null automatically?
Thnx in advance


Go to Top of Page

adnanans78
Starting Member

17 Posts

Posted - 2007-08-31 : 06:30:50
Hi,
This is an other problem for me.I want the records which are modified or deleted at query execution time.Like virtual inserted or deleted tables do.These have limitation of data types.These tables could solve my problem if do not have such limitations.
Is there any other way?
thnx in advance.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-31 : 07:15:59
no. not really.
in sql server 2005 you have the output statement for this...

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -