Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 20th, 2005, 06:23 PM
Registered User
Join Date: Jan 2005
Location: los angeles, ca, USA.
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 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

Reply With Quote
  #2 (permalink)  
Old October 21st, 2005, 01:42 PM
Authorized User
Join Date: Oct 2005
Location: , , .
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts

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


SQL Server Helper
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 09:02 AM.

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