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 |
|
qwer
Starting Member
1 Post |
Posted - 2005-01-11 : 02:46:15
|
| Hi I want to create a trigger that copies a text column datatype from one database to another database in a specific text column.to be more precise I use a trigger in one database , and when an insert happens I want to copy the text column in the other databaseHow I do it ? |
|
|
amachanic
SQL Server MVP
169 Posts |
Posted - 2005-01-11 : 13:43:57
|
Something like this, perhaps:CREATE TRIGGER tg_MoveTextON YourTableFOR INSERT ASBEGIN IF @@ROWCOUNT = 0 RETURN INSERT YourOtherDB..YourOtherTable (YourTextCol, YourPK) SELECT YourTextCol, YourPK FROM INSERTEDEND |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-01-11 : 13:57:48
|
| I forget the circumstances, but I don't think a text column is available, for this type of job, from INSERTED unless you do an INSTEAD OF TRIGGER is it?But there again I may just be barking ....Kristen |
 |
|
|
amachanic
SQL Server MVP
169 Posts |
Posted - 2005-01-11 : 15:01:48
|
| Nope, I just tested and you're completely correct...However, this does work:use tempdbgocreate table blah (blah1 text, pk int)gocreate trigger tg_blahon blahfor insert asbegin select blah1 from blah where pk in (select pk from inserted) endgoinsert blah values ('blah', 1)godrop trigger tg_blahdrop table blahgo |
 |
|
|
|
|
|