Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 25th, 2005, 07:51 AM
Authorized User
 
Join Date: Jun 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trigger not working - please help

Hi,

The trigger below does not seem to work?

I have 2 tables:
ecastdata
ecastbounces

When the 'ecastdata' table gets updated with certain criteria I want those records to be copyed into the 'ecastbounces' table.
For some reason the trigger does not work?

I think it might be going wrong with this bit of code?:
(Select max(ecastdata.EcastID) from ecastdata) AND BounceHard > 0


------Trigger--------------

CREATE TRIGGER InsBouncesTR
ON ecastdata

FOR UPDATE

AS

INSERT INTO ecastbounces (ID, EcastID, Email)
SELECT Email FROM ecastdata WHERE EcastID = (Select max(ecastdata.EcastID) from ecastdata) AND BounceHard > 0

----------------------------

Any Ideas

PLEASE HELP!

 
Old November 25th, 2005, 09:39 AM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

HMan,

The number of columns in INSERT INTO statement do not match your SELECT. You are insterting into 3 columns but only selecting 1:

INSERT INTO ecastbounces (ID, EcastID, Email)
SELECT Email FROM...

The number of columns must be equal. For example:

INSERT INTO ecastbounces (ID, EcastID, Email)
SELECT Email, column2, column3 FROM...

Scott

 
Old November 25th, 2005, 11:25 AM
Authorized User
 
Join Date: Jun 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot Scott.

It was my silly mistake, doh :)

 
Old November 25th, 2005, 12:06 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

No problem hman. Glad I could help.

Scott






Similar Threads
Thread Thread Starter Forum Replies Last Post
window.opener working .... not working alyeng2000 Javascript How-To 5 January 5th, 2007 08:05 AM
Web.Config..Working or Not Working peace95 ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2006 06:53 AM
do I need a trigger? Warbird SQL Server 2000 1 April 5th, 2005 08:07 AM
Local COM working , but not working at Web Serv nagen111 .NET Web Services 3 February 19th, 2005 04:22 AM
Using instead of trigger dmr999 SQL Server 2000 1 November 29th, 2003 02:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.