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)
 STRANGE PROBLEM IN SQL SERVER 2005

Author  Topic 

SHIVPREET2K1
Starting Member

32 Posts

Posted - 2008-06-23 : 08:20:07
Dear Friends

I am trying to create a trriger in sql server 2005 but it gives me error. i am unable to understand the problem . here is detail about it

Database name :- Orders

table name :- Currency_Master

Columns are :- Currency_Symbol, Currency_Name, Value_in_Rs

The create trigger query is


CREATE TRIGGER FOR ORDERS ON CURRENCY_MASTER
AFTER INSERT

AS SELECT 'CURRENCY_SyMBOL'


Can any body tell that why it gives an error and how to rectify it.

Thanks in advance.

Shivpreet2k1



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-23 : 08:21:52
Remove FOR & try.For is actually used in place of AFTER
CREATE TRIGGER FOR ORDERS ON CURRENCY_MASTER
AFTER INSERT

AS SELECT 'CURRENCY_SyMBOL'
Go to Top of Page

SHIVPREET2K1
Starting Member

32 Posts

Posted - 2008-06-23 : 08:25:51
thanks for the reply


i done this as u have said

CREATE TRIGGER FOR ORDERS ON CURRENCY_MASTER
AFTER INSERT

AS SELECT 'CURRENCY_SyMBOL'


now it gives the following error

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'FOR'.

what could be possible reason for this strange behaviour

Thanks for ur reply

shivpreet2k1
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-23 : 08:31:45
quote:
Originally posted by SHIVPREET2K1

thanks for the reply


i done this as u have said

CREATE TRIGGER FOR ORDERS ON CURRENCY_MASTER
AFTER INSERT

AS SELECT 'CURRENCY_SyMBOL'


now it gives the following error

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'FOR'.

what could be possible reason for this strange behaviour

Thanks for ur reply

shivpreet2k1


i told you to remove it

CREATE TRIGGER ORDERS ON CURRENCY_MASTER
AFTER INSERT

AS SELECT 'CURRENCY_SyMBOL'
Go to Top of Page

SHIVPREET2K1
Starting Member

32 Posts

Posted - 2008-06-23 : 08:33:18
Sorry bro

you were right. it was my mistake. now the trigger is running fine.

Thanks again

shivpreet2k1
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-23 : 08:36:07
quote:
Originally posted by SHIVPREET2K1

Sorry bro

you were right. it was my mistake. now the trigger is running fine.

Thanks again

shivpreet2k1


Ok. thats fine. and i assume that the posted trigger was for illustration. You dont require trigger to display some inserted field values. You can use OUTPUT clause for it.
Go to Top of Page
   

- Advertisement -