Click here to Skip to main content
16,004,836 members
Home / Discussions / Database
   

Database

 
AnswerRe: How to restore records from table which is dropped. Pin
ToddHileHoffer1-Aug-06 3:05
ToddHileHoffer1-Aug-06 3:05 
QuestionHow to retrieve records from a ADODB with c# Pin
VanEtienne1-Aug-06 2:57
VanEtienne1-Aug-06 2:57 
AnswerRe: creating special relations between datatables Pin
ToddHileHoffer1-Aug-06 2:52
ToddHileHoffer1-Aug-06 2:52 
GeneralRe: creating special relations between datatables Pin
yiwpyos17-Aug-06 23:45
yiwpyos17-Aug-06 23:45 
QuestionFirewall problem Pin
johan31311-Aug-06 1:54
johan31311-Aug-06 1:54 
QuestionAccessing 2 databases [modified] Pin
mcgann1-Aug-06 1:01
mcgann1-Aug-06 1:01 
AnswerRe: Accessing 2 databases Pin
ToddHileHoffer1-Aug-06 3:02
ToddHileHoffer1-Aug-06 3:02 
QuestionInsert multiple values through Trigger Pin
DineshSharma1-Aug-06 0:05
DineshSharma1-Aug-06 0:05 
Hi frends
I have written a trigger in MS-SQL 2000 runing successfully to insert single row.....but if i need to insert multiple rows from a select query in this trigger ......I am Confused ? Confused | :confused:
Purpose of Trigger
whenever a column will be updated in a table the data from two tables will be inserted into two tables where one table has multiple rows to insert.

I am trying to use While loop but confused that what should be the condition there to break tha loop......pls help if someone knows. Confused | :confused:
My trigger is

IF (COLUMNS_UPDATED() ) > 49
BEGIN
Declare @ServerDate datetime;
Declare @TranID numeric(18,0);
Declare @OppID numeric(18,0);
Declare @ProductID int;
Declare @Qty int;
Declare @Cost numeric(18,2);
Declare @Price numeric(18,2);
Declare @Discount numeric(18,2);
Declare @TaxAmt numeric(18,2);
Declare @UserID numeric(18,0);
Declare @ContactID numeric(18,0)
Declare @CountProduct int


SELECT @ServerDate=getdate()
SELECT @OppID=Opp.OppId, @ContactID=Opp.ContactID, @UserID=Opp.UserID FROM Opportunity Opp INNER JOIN INSERTED ON Opp.OppId = INSERTED.OppId where Inserted.StatusID=3

if (Convert(varchar(10),@OppID) != '')
BEGIN
INSERT INTO [Transaction] (OppID,TranDate, ContactID,UserID) values (@OppId, @ServerDate, @ContactID, @UserID)

SELECT @TranID=TranID from [Transaction] where TranDate=@ServerDate
SELECT @ProductID=Opp.ProductID, @Qty=Opp.Qty, @Cost=Opp.Cost, @Price=Opp.Price, @Discount=Opp.Discount, @TaxAmt=Opp.TaxAmt FROM vOpportunityList Opp INNER JOIN INSERTED ON Opp.OppId = INSERTED.OppId where Inserted.StatusID=3
--Count row
SELECT @CountProduct=count(Opp.ProductID) FROM vOpportunityList Opp INNER JOIN INSERTED ON Opp.OppId = INSERTED.OppId where Inserted.StatusID=3

--WHILE (-----------)
--BEGIN
INSERT INTO [TranProduct] (TranID,ProductID,Qty,Cost,Price,Discount,TaxAmt) values(@TranID, @ProductID, @Qty, @Cost, @Price, @Discount, @TaxAmt)

--END
END
END


Dinesh Sharma

AnswerRe: Insert multiple values through Trigger Pin
ToddHileHoffer1-Aug-06 2:59
ToddHileHoffer1-Aug-06 2:59 
GeneralRe: Insert multiple values through Trigger Pin
DineshSharma2-Aug-06 2:44
DineshSharma2-Aug-06 2:44 
QuestionSQL Scripting in a Batch File Pin
Programm3r31-Jul-06 23:45
Programm3r31-Jul-06 23:45 
QuestionSQL Scripting in a Batch File Pin
Programm3r31-Jul-06 23:42
Programm3r31-Jul-06 23:42 
AnswerRe: SQL Scripting in a Batch File Pin
seea3-Aug-06 0:34
seea3-Aug-06 0:34 
Questioncreating special relations between datatables Pin
yiwpyos31-Jul-06 21:38
yiwpyos31-Jul-06 21:38 
QuestionHelp with database permissions (URGENT) Pin
johan313131-Jul-06 21:31
johan313131-Jul-06 21:31 
AnswerRe: Help with database permissions (URGENT) Pin
Frank Kerrigan31-Jul-06 22:18
Frank Kerrigan31-Jul-06 22:18 
GeneralRe: Help with database permissions (URGENT) [modified] Pin
johan313131-Jul-06 23:02
johan313131-Jul-06 23:02 
GeneralRe: Help with database permissions (URGENT) Pin
ToddHileHoffer1-Aug-06 3:08
ToddHileHoffer1-Aug-06 3:08 
Questionfirst 10 rows Pin
dansoft31-Jul-06 20:01
dansoft31-Jul-06 20:01 
AnswerRe: first 10 rows Pin
Edbert P31-Jul-06 20:10
Edbert P31-Jul-06 20:10 
GeneralRe: first 10 rows Pin
Frank Kerrigan31-Jul-06 22:21
Frank Kerrigan31-Jul-06 22:21 
AnswerRe: first 10 rows Pin
Ennis Ray Lynch, Jr.1-Aug-06 4:49
Ennis Ray Lynch, Jr.1-Aug-06 4:49 
Questionis this the right forum Pin
weelze31-Jul-06 16:44
weelze31-Jul-06 16:44 
AnswerRe: is this the right forum Pin
Frank Kerrigan31-Jul-06 22:21
Frank Kerrigan31-Jul-06 22:21 
AnswerRe: is this the right forum Pin
S Douglas1-Aug-06 21:50
professionalS Douglas1-Aug-06 21:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.