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 |
|
watherton
Starting Member
6 Posts |
Posted - 2004-09-14 : 08:45:40
|
| Hi guys, can someone lend me a hand a figuring out why my trigger is not working.here is the trigger code:CREATE TRIGGER [TDataDump]ON [dbo].[DataDump] for updateASDeclare @HalNum char(10), @OldHalNum char(10), @ProductDesc char(50), @Vendor char(10), @VendorNum char(10), @Brand char(10), @PackType char(10), @CutterReq char(10), @PhotoReq char(10), @Barcode char(10)Select @HalNum = HalNum from insertedSelect @OldHalNum = OldHalNum from insertedSelect @ProductDesc = ProductDesc from insertedSelect @Vendor = Vendor from insertedSelect @VendorNum = VendorNum from insertedSelect @Brand = Brand from insertedSelect @CutterReq = CutterReq from insertedSelect @PhotoReq = PhotoReq from insertedSelect @Barcode = Barcode from insertedinsert [dbo].[ProjectLines] values(@HalNum,@OldHalNum,@ProductDesc,@Vendor,@VendorNum,@Brand,@PackType,@CutterReq,@PhotoReq,@Barcode)The data is inserted into the DataDump table from a dts package.CheersWayne |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-09-14 : 08:49:54
|
If the data in inserted, this won't work. You need a FOR INSERT trigger. Also, if you are inserting multiple rows, this trigger isn't going to work anway. You would need something like this:CREATE TRIGGER TDataDumpON dbo.DataDump FOR INSERTASINSERT ProjectLines( HalNum, OldHalNum, ProductDesc, Vendor, VendorNum, Brand, CutterReq, PhotoReq, Barcode) SELECT HalNum, OldHalNum, ProductDesc, Vendor, VendorNum, Brand, CutterReq, PhotoReq, Barcode FROM inserted MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
watherton
Starting Member
6 Posts |
Posted - 2004-09-14 : 10:56:44
|
| Derrick thanks for that, the trigger works fine when I use upate ProjectLines(HalNum)values('1') but does nothing when my code enters the data. I created a dts package and the saved it as .bas file, converted that file into c#, this code works because it enters the data into the datadump table, but does not fire off the trigger.any suggestions?wayne |
 |
|
|
watherton
Starting Member
6 Posts |
Posted - 2004-09-14 : 11:09:17
|
| Derrick this is well wierd. My converted dts code works fine (except that it does not fire off the trigger). The dts package run from with Enterprise Manager works and also fires off the trigger. aarrrhhh, is this a security issue - I am using impersonation in order to execute the dts code.well strange |
 |
|
|
|
|
|
|
|