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 October 20th, 2005, 06:23 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert tigger dont work multiple

below is my code to copy from invoices(header) to ca_temp_invoices.
then trigger should be work to copy x_invoic(detail) to ca_temp_x_invoic.

if I copy 4 invoice in to temp_invoices, then I should have all 4 x_invoic(deatil) information should be copyed in to ca_temp_x_invoic but only copy 1 of last inovoice number detail is copyed in to ca_temp_x_invoic. "CAN SOMEBODY HELP". I been reading professional SQL Server 2000 Programming book for couple days to find but couldn't.

"My Trigger begins"

CREATE Trigger CA_Temp_X_inv_Ins_Del on dbo.ca_temp_invoices for
insert as

Declare @status tinyint
Declare @doc_no varchar (15)


select @status=inserted.status, @doc_no=inserted.doc_no from inserted

if @@rowcount = 0 return -- no rows affected, exit immediately
 if @doc_no = null return

BEGIN
Begin Tran

    insert ca_temp_x_invoic
    select * from x_invoic where status=@status and order_no=@doc_no and desc_type=1

    --exec CA_Insert_T_inv @status, @doc_no
COMMIT
END


 
Old October 21st, 2005, 01:42 PM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try it this way:

CREATE Trigger CA_Temp_X_inv_Ins_Del on dbo.ca_temp_invoices for
insert as

INSERT INTO ca_temp_x_invoic
SELECT x_invoic.*
FROM x_invoic INNER JOIN inserted
  ON x_invoic.order_no = inserted.doc_no

END

SQL Server Helper
http://www.sql-server-helper.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sessions dont work melkin ASP.NET 1.0 and 1.1 Professional 6 April 12th, 2007 01:17 PM
Web Parts dont work on my PC savan_thakkar ASP.NET 2.0 Professional 0 October 10th, 2006 08:10 AM
*.do URLs dont work in apache web server+tomcat haomomo Struts 1 August 29th, 2006 09:57 AM
Samples dont work Jags .NET Framework 2.0 1 April 22nd, 2005 09:39 AM
ch10 p 404 server.URLEncode dont work :( Timmo BOOK: Beginning ASP 3.0 0 February 3rd, 2004 03:44 PM





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