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)
 Triggers

Author  Topic 

mapidea
Posting Yak Master

124 Posts

Posted - 2010-03-06 : 18:34:48
I have a question on best practises in Triggers.

I have a table in which I am improting Order information (Table Name – Data_Imported).

Now I want to create a Order in the same database from the imported data.
If I create a After Trigger On Insert for (Data_Imported) on the table and get all the inserted data and create a order in Orders table by inserting data.

Is this a good practise?

I have read that there are performance issues when the trigger executes query on other tables.

http://msdn.microsoft.com/en-us/magazine/cc164032.aspx In the last paragraph he says " One situation in which triggers are not efficient is when the trigger must perform queries against other tables."

Even if this is a good practice are their any alternate solution. or should I create a Order in Orders table when importing itself rather than using triggers on Data_Imported table.
Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-06 : 20:10:48
Could you show us a data example of what you mean?

To me it sounds like you can create the order during the import process rather than having a trigger do it. I need to see some data though.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-07 : 02:25:25
whats the order info you're importing? are you trying to clone new orders from it?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -