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 2008 Forums
 SQL Server Administration (2008)
 Trigger update script

Author  Topic 

Zangetsu
Starting Member

6 Posts

Posted - 2014-06-30 : 22:01:53
Hi guys,

I'm brand new to SQL triggers and scripting and need some assistance if you have the time...

I need to update a specific column in a table when any changes are made to the master column for example:

Database: Test1
Table: dbo.STK_ProdPrices
Column: CostAve
If any changes are made to this column in any row, I need to update the specific row in that column.

Database: Test2
Table: dbo.CostAve
Column: CostAve

How would the script be written?
(sorry is this might be a Noob question but as I mention I'm very new to this)



Always trying to make the impossible, possible

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-01 : 12:34:13
Show us what you have so far. And why a trigger? I'd probably use transactional replication instead.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Zangetsu
Starting Member

6 Posts

Posted - 2014-07-01 : 14:19:14
Hi Tara Kizer,

My initial thought was to use replication but had a few comments on a different forum saying that triggers might be the safer/better way to go.

At the moment I have started going through the main database finding all the data tables that I would need to work on. I should get another branches database in the next day or two so that I can start testing(playing) to see what works and what does not. As soon as I have it I will post what I have tried so far, hopefully you might be able to assist where I get stuck.

quote:
Originally posted by tkizer

Show us what you have so far. And why a trigger? I'd probably use transactional replication instead.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/



Always trying to make the impossible, possible
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-01 : 14:33:29
http://msdn.microsoft.com/en-us/library/ms187326.aspx

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -