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.
| Author |
Topic |
|
tcv56
Starting Member
12 Posts |
Posted - 2007-02-01 : 14:45:51
|
| Hi all,Can you show me:1) how to export data from a table (in db1) to another table in (db2)? 2) use of trigger for this kind of task.My db1 & db2 are in different physical location/servers.db1:table1: f1, f2, f3db2:table1: col1, col2, col3db3:table1: ncol1, ncol2, ncol3if f2 (of db1) = 99 (update or delete case) copy col1, col2 & col3 (of db2) to db3 where f3 (of tb1)= col2 (of table2) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-02-01 : 15:13:15
|
| You've got lots of options. Here are 3 of them:1. T-SQL using linked server2. DTS import/export wizard or create a package3. bcp out to file/bcp in from fileTara Kizer |
 |
|
|
tcv56
Starting Member
12 Posts |
Posted - 2007-02-01 : 15:28:00
|
| I am more interested in learning all that trigger syntax that automate the process. If you dont mind, can you show me how a trigger is fire that in turn invoke a store procedure (doing the exporting/copy data from one table to another). Thanks |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-02-01 : 15:32:41
|
| Triggers are well documented in SQL Server Books Online. If you go the trigger route, then you'll be using option1 listed in my last post. Option1 requires a linked server to exist. Linked servers are documented in SQL Server Books Online as well. Here's an example using one though:INSERT INTO LinkedServerName.DatabaseName.dbo.TableName (Column1, Column2)SELECT Column1, Column2FROM TableNameWHERE ...For triggers, you would use the inserted table:INSERT INTO LinkedServerName.DatabaseName.dbo.TableName (Column1, Column2)SELECT Column1, Column2FROM insertedTara Kizer |
 |
|
|
|
|
|
|
|