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 2005 Forums
 Transact-SQL (2005)
 how to create trigger on temp table

Author  Topic 

khusiie
Yak Posting Veteran

78 Posts

Posted - 2008-01-29 : 10:57:46
CREATE TRIGGER Triggermyorderstest
ON myorderstest
INSTEAD OF INSERT
AS

DECLARE @COL_COUNT INT

SELECT @col_count = COUNT(NUM)
FROM myorderstest
WHERE (NUM LIKE 'no%')


if @col_count IS NOT NULL
raiserror('cannot insert into table- trigger completed successfully',16,11)

GO

i have to create a temp table and apply the trigger to temptable Then i can insert some data into the temp table to see if it gets inserted into target table myorderstest...

how can i do it? can anyone help me?

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-29 : 12:35:59
which is your temp table? you need to specify its name on trigger definition

CREATE TRIGGER Triggermyorderstest
ON yourtemptable
Go to Top of Page

khusiie
Yak Posting Veteran

78 Posts

Posted - 2008-01-29 : 12:42:23
quote:
Originally posted by visakh16

which is your temp table? you need to specify its name on trigger definition

CREATE TRIGGER Triggermyorderstest
ON yourtemptable



temp table is : #temptaborder

but i m getting error - it says taht u can't create trigger on temporary object...

actually i want to create the trigger on one table - myorderstest:
and want to see if it populates other table myorders.

how can i do it?
is it possible...that's why i tried temporary table but i think i am wrong..as trigger can't creat on temporary table...

can u give me suggetion plz.

thanks.



Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-01-29 : 15:19:41
quote:
Originally posted by khusiie

how to create trigger on temp table
Are you nuts?

e4 d5 xd5 Nf6
Go to Top of Page
   

- Advertisement -