Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Trigger To Insert Data Into A Notepad


Good Day All

I want to create a trigger that will send records INSERTED into a notepad. Can you please help with the syntax

CREATE TRIGGER Test ON [Table1]
FOR INSERT
NOT FOR REPLICATION
AS
/*Instead of Inserting into another table, I WANT TO INSERT DATA INTO A NOTE PAD WITH 3 VARIABLES
*/




View Complete Forum Thread with Replies

Related Forum Messages:
How Can I Prevent That All Data Can Be Seen With Notepad?
Hello,

is there a way to say to SQL Server to make the data not readable?

Regards
Markus

 

 

 

View Replies !
How To Link Mssql Data (tables) In Notepad (HTML)
menardo writes "Hi there!
I'm a very newbie in SQL programming. Can anybody help me how do I start to learn scriptings.

Can you give me the process or scripts on how to export it??

Thanks in advance.

-menardo"

View Replies !
How Can I Create A DTS Package To Update A Table With Data From A Notepad File ?
 

We are creating a process which will create a notepad file with a set of Unique key which we use to update the database. Am trying to create a DTS package to accomplish this...but it seems to be a trivial task. I can use Transform data task to lookup the text file but i need to write an update query which will update some fields of existing records.
Am not sure how can i map fields of Text file to the Database table field.
 
If any1 can help then it will be great

View Replies !
How To Insert New Data In Trigger
In oracle, I use the following script in trigger:
INSERT INTO TABLE1 (CITY, STATE) VALUES (:new.city,:new.state);

I am wondering how to insert new data in SQL server. Thanks!

View Replies !
Insert Data In Update Trigger
I have a table called drugs with a cost, date, and drugname field. I have a history table that I want to insert into anytime the fields are changed in the drugs table. I want to capture the old data along with the new cost. is that possible in a update trigger? What I have below doesn't like when it comes to setting the new cost

create trigger Updt_drugs on drugs for update as
-- updates record with sql user and timestamp
--created 1-12-02 tim cronin
declare @newcost money
begin
set @newcost = select cost from inserted
insert into drugsold ([oldcost],[cost],[cdate],[drug])
select [cost],@newcost,[cdate],[drug]
from deleted dt
end

View Replies !
Insert Trigger Not Getting Row Data For Email Body
hello,
need help with a simple trigger i have been working on. the trigger automatically sends me an email out when a record is inserted, how ever i can't seem to get the row column data into the email. The part i do not understand is that I get the row column data  information in the email if I update the row.
This is for 2005 SQL
Any direction would be greatly appreaciated
OneIDesigned
 

View Replies !
Using Trigger To Insert Data To Different Server Database
i have 2 server named A and B

in A server have database server and B have database server

in A have database named A1 with table TA1 and in B have database named B1 with table TB1

i want if i insert data into database A1 table TA1 in server A, database B1 table TB1 in server B will insert the same data to

how can do that with trigger or other ways

thx u

View Replies !
Insert Data To MSSQL Within Trigger From Oracle
I created a link from Oracle to SQL server.
There is a trigger with insert statment in Oracle side.
I got error message as follow when trigger is invoked:

SQL> insert into test1 values ('zerbra','brazi');
insert into test1 values ('zerbra','brazi')
*
ERROR at line 1:
ORA-02047: cannot join the distributed transaction in progress
ORA-06512: at "GGWEB.TRIGGER2", line 4
ORA-04088: error during execution of trigger 'GGWEB.TRIGGER2'

my simple trigger is as follows:
create or replace
TRIGGER TESTRI
AFTER INSERT ON TEST1
FOR EACH ROW
BEGIN
insert into test1@sqlserver (city,state) values ('what','nine');


END;

View Replies !
Trigger Not Execute Some Data Or Insert Not Execute A Trigger For Some Data
I have trigger, but not execute somedata because insert few row in every second. I use java to insert data to SQL server 2005.  Data inserted to a table but not executing trigger for some data.
For example 100 data every second inserted to a table.

If insert data one by one to a table trigger fires success.
Please Help me.

View Replies !
Importing Data In Datatable Using SSIS Package Trigger On Insert Is Not Firing On That Table
Hi
I am Importing data in datatable using SSIS package . I made trigger on that table on insert. The trigger on insert is not firing on that table
Please help
Thanks
CP

View Replies !
Trigger - Require Help For Updating A Trigger Following An INSERT On Another Table
A





ID

Name


1

Joe


2

Fred


3

Ian


4

Bill
 
 
B





ID


1


4
 
I want to be able to create a trigger so that when a row is inserted into table A by a specific user then the ID will appear in table B.  Is it possible to find out the login id of the user inserting a row?
 
I believe the trigger should look something like this:
 
create trigger test_trigger
on a
for insert
as
insert into b(ID)
 
select i.id
from inserted i
where
--specific USER

View Replies !
Trigger - Require Help For Updating A Trigger Following An INSERT On Another Table
Table 1
 




First_Name

Middle_Name

Surname


John

Ian

Lennon


Mike

Buffalo

Tyson


Tom

Finney

Jones
 
Table 2




ID

F

M

S

DOB


1

Athony

Harold

Wilson

24/4/67


2

Margaret

Betty

Thathcer

1/1/1808


3

John

Ian

Lennon

2/2/1979


4

Mike

Buffalo

Tyson

3/4/04


5

Tom

Finney

Jones

1/1/2000
 
 
I want to be able to create a trigger that updates table 2 when a row is inserted into table 1.  However I€™m not sure how to increment the ID in table 2 or to update only the row that has been inserted.
 
 

View Replies !
SQL Server To C++ Or Notepad
Basically I'm working on a Web page in ASP.NET, we the nhave our SQL server database, and inside we have C++ which needs to be able to go through incoming files and perform some operations, as well as enter it into the SQL database, and retrieve information from it. But we haven't the foggiest as how to go about doing thing, our C++ programmer doesn't know how to set up a connection from SQL to his code. IS there A) a program that will convert the SQL data into a text file for him to read from with C++. B) A GOOD book that he can pick up that will help bridge the gap between his knowledge and the knowledge required. So far google hasn't represented much luck. Any advice pertaining to some way to allow our C++ guy to learn/or enable him to read data and insert data into a SQL server would be GREATLY appreciated.

View Replies !
Output In Notepad
hi friends,
Can any one tell how to save the O/P to notepad.@tmp variable output need to be stored in notepad

Create procedure testing
as
begin
set nocount on

--open cursor
print @tmp
--close cursor

set nocount off

View Replies !
Multiple Insert Call For A Table Having Insert Trigger
Hi

I am trying to use multiple insert for a table T1 to add multiple rows.

Ti has trigger for insert to add or update multiple rows in Table T2.

When I provide multiple insert SQL then only first insert works while rest insert statements does not work

Anybody have any idea about why only one insert works for T1

Thanks

View Replies !
Creating Notepad File Through SQL Server 2005
Hi friends,              Is there any way to create a text file or word file through sql server 2005.If you have any source please suggest me.. P.Kumaran 

View Replies !
Error When Importing Text File - Saving In Notepad First Works
I'm trying to import a tab separated text file into sql server 2005 using the import guide. But when running the job I get the error message

Error 0xc02020c5: Data Flow Task: Data conversion failed while converting column "Column 19" (67) to column "Column 19" (404). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
(SQL Server Import and Export Wizard)

The column 19 which reported a problem contains this information:
?searchroot=/_gen_/txt/&template=std.htm&use=prospect&intref=1_26067

However what is mysterious is that if I open the file in notepad or Excel and resave it again the job runs perfectly. This is not a way we could make it work later on since it's an automatic job that will run each night on a new text file.

The text file is sent from Norway to Sweden - and I use ANSI latin 1 when importing.

The column has datatype DT_STR with a width of 500.

I use Locale Swedish and when I save in Notepad it is saved in ANSI,

I use Windows XP Swedish version.

View Replies !
Insert Trigger For Bulk Insert
In case of a bulk insert, the “FOR INSERT� trigger fires for each recod or only once?
Thanks,

View Replies !
Interaction Between &&"instead Of Insert&&" Trigger And Output Clause Of Insert Statement
 
This problem is being seen on SQL 2005 SP2 + cumulative update 4
 
I am currently successfully using the output clause of an insert statement to return the identity values for inserted rows into a table variable
 
I now need to add an "instead of insert" trigger to the table that is the subject of the insert.
 
As soon as I add the "instead of insert" trigger, the output clause on the insert statement does not return any data - although the insert completes successfully.  As a result I am not able to obtain the identities of the inserted rows
 
Note that @@identity would return the correct value in the test repro below - but this is not a viable option as the table in question will be merge replicated and @@identity will return the identity value of a replication metadata table rather than the identity of the row inserted into my_table
 
Note also that in the test repro, the "instead of insert" trigger actually does nothing apart from the default insert, but the real world trigger has additional code.
 
To run the repro below - select each of the sections below in turn and execute them
1) Create the table
2) Create the trigger
3) Do the insert - note that table variable contains a row with column value zero  - it should contain the @@identity value
4) Drop the trigger
5) Re-run the insert from 3) - note that table variable is now correctly populated with the @@identity value in the row
 
I need the behaviour to be correct when the trigger is present
 
Any thoughts would be much appreciated
 
aero1
 
 
/************************************************
1) - Create the table
************************************************/
CREATE TABLE [dbo].[my_table](
      [my_table_id] [bigint] IDENTITY(1,1)  NOT NULL,
      [forename] [varchar](100)  NULL,
      [surname] [varchar](50)  NULL,
 CONSTRAINT [pk_my_table] PRIMARY KEY NONCLUSTERED
(
      [my_table_id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 70) ON [PRIMARY]
)
 
GO
/************************************************
2) - Create the trigger
************************************************/
CREATE TRIGGER [dbo].[trig_my_table__instead_insert] ON [dbo].[my_table]
INSTEAD OF INSERT
AS
BEGIN
 
      INSERT INTO my_table
            (
            forename,
            surname)
      SELECT
            forename,
            surname
      FROM inserted
 
END
 
/************************************************
3) - Do the insert
************************************************/
 
DECLARE @my_insert TABLE( my_table_id     bigint )
 
declare                 @forename                     VARCHAR(100)
declare                 @surname                      VARCHAR(50)
 
set         @forename = N'john'
set         @surname = N'smith'
 
INSERT INTO my_table (
                                     forename
                                    , surname
                                    )
OUTPUT inserted.my_table_id INTO @my_insert
VALUES(       @forename
            , @surname
            )
 
select @@identity  -- expect this value in @my_insert table
select * from @my_insert -- OK value without trigger - zero with trigger
 
/************************************************
4) - Drop the trigger
************************************************/
 
drop trigger  [dbo].[trig_my_table__instead_insert]
go
 
/************************************************
5) - Re-run insert from 3)
************************************************/
-- @my_insert now contains row expected with identity of inserted row
-- i.e. OK
 

View Replies !
Insert Trigger
I would like to have the value of a field to be set the return value of
System.Web.Security.Membership.GeneratePassword(12,4)
every time a a row is inserted.
Can you guide with this?
Do you have  some similar sample code?
Thank you very much

View Replies !
Insert Trigger - How To
 I would like to have the value of a field to be set the return value of
System.Web.Security.Membership.GeneratePassword(12,4)
every time a a row is inserted.
Can you guide with this?
Do you have  some similar sample code?
Thank you very much

View Replies !
Insert Trigger Help
Hello,I'm new with triggers and I can not find any good example on how todo the following:I have two tables WO and PM with the following fields:WO.WONUM, VARCHAR(10)WO.PMNUM, VARCHAR(10)WO.PROBLEMCODE, VARCHAR(8)WO.LABORGROUP, VARCHAR(8)PM.PMNUM, VARCHAR(10)PM.PROBLEMCODE, VARCHAR(8)PM.LABORGROUP, VARCHAR(8)When creating a new record on WO I need to create an INSERT TRIGGERthat will pass the data below from PM to WO when WO.PMNUM = PM.PMNUMPM.PROBLEMCODE to WO. PROBLEMCODE andPM.LABORGROUP to WO. LABORGROUPCould anybody please show me how to do this or point me to the rightdirection, any help will be greatly appreciated.Thanks!Martin

View Replies !
Insert Trigger
HiI have a table - DebtorTurnover - consisting of 5 fields (ID, Date,Turnover, VAT, Netturnover). I get a file which I have to import everyknow and then, with new data. In this file I only get values for (ID,Date, Turnover and VAT). The import is working fine with the importwizard.The problem is, that I want to have the Netturnover computed at thetime of insert to equal [Turnover-VAT], but I don't really know how toas I'm new to these triggers.Could anyone help me I would appriciate this.BR / Jan

View Replies !
Trigger INSERT Q
Really simple question - I have the following trigger for the INSERT event for Tbl_B:

CREATE TRIGGER calc_total ON [dbo].[Tbl_B]
FOR INSERT
AS

DECLARE @VATRate AS decimal(19,2)
SET @VATRate = (
SELECT Val
FROM Tbl_Numeric_Refs
WHERE Ref = 'VATRate'
)

UPDATE Tbl_B
SET [Total] = ((@VATRate / 100) * [PriceA]) + [PriceA],
[VATRate] = @VATRateHow can I restrict the UPDATE within the trigger to the record(s) being INSERTed? Or am I over-complicating things, and should use a simple UDF for this instead?

View Replies !
Trigger On Insert
Is it possible to pick up the value that is being inserted within the scope of a trigger? For example, if I were to run the following

INSERT INTO people (firstname, lastname)
VALUES ('George', 'V')

Would it be possible to access these values in a trigger before they are inserted?

CREATE TRIGGER trigger1
ON people
FOR INSERT
AS
IF EXISTS (SELECT 1 FROM table1 WHERE firstname = <the value being inserted>) BEGIN
Print '1'
END
ELSE BEGIN
Print '2'
END
GO

View Replies !
SQL Trigger To Run On Insert Only
Rightio - this is probably a simple question for you SQL afficionados.I have written a trigger to update a master table with a CreateDate field. Simple enough I thought but it updates this field when the existing record is edited as well - not so good.This is how it looks like:CREATE TRIGGER CreateDateON MasterFOR UPDATE ASDECLARE@idMaster intSELECT @idMaster = idMaster from Insertedupdate Masterset CreatedDate = getdate()where idMaster = @idMasterGOWell I know I can write an IF statement that will basically say if the field is not null then only update - fair enough - but is there a simpler way to do this? Is there a way I need to write my CREATE TRIGGER statement that ONLY makes it run when it is a NEW INSERT ONLY?THANKS!

View Replies !
Trigger: Before Insert
Hi, i'm a newbie in writting trigger and stored procedure, need to get help on this:

I cannnot find anyway to run the trigger before insert, anyway to do this?

Thanks.

View Replies !
Trigger INSTEAD OF INSERT??
So... dear friends
I want to insert values to a table without firing the foreign key Constraint.
I think one way is to insert values into the parent table first and then perform the initial insert.
Is this possible with an INSTEAD OF INSERT Trigger or another way? If yes can you make an example? I want to check for dublicate values in the parent table too!!
Thanx!

View Replies !
Insert Trigger
I am trying to write an insert trigger for the following problem. I have a table that contains a field (amount) that contains currency amount. Each row could be a record from a transaction in a different country. I would like each record to be converted into U.S. currency as it is inserted. So I created an other table that contains that exchange rate. How can I create a trigger that does this?

Tax Detail Table Exchange Table

Account# int Country char
Description char ExchangeRate Money
Amount money
Country char

I am working with MSS 6.5. Any and all help will be greatly appreciated.

Fidencio Peńa

View Replies !
ON INSERT TRIGGER
MSSQL 6.5

Is there any way to change some columns on inserted lines in ON INSERT trigger?

My notice: I try to find something about it in SQLBOOKS, but I found nothing.
It's possibly not TRUEEE!!!!! It wants me to grumble.


Thank for your answer.

View Replies !
Pre-insert Trigger
I am trying to write a pre-insert trigger. I want a row to be deleted first and then have the new row inserted. The end result is an insert/update statement. If anyone knows how to do this or has a better way, let me know, Please.

View Replies !
Insert Trigger
I am having problems with my triggers

I have 2 triggers, a insert and an update.

My insert, copies all the values from the inserted table to a temp table.


MY update deletes any values in the deleted table from the temp table and then inserts all the values from the inserted table into the temp table.

The problem is, when I perform an insert the insert trigger fires and then for some odd reason the update trigger fires as well.

Here is the code for the insert trigger that for some reason seems to firing the update trigger after it is fired..


*************************
insert into T_output_epacodes(output_id, epa_code, last_update, updated_by)
select output_id, epa_code, last_update, updated_by from Inserted

***************************


Any ideas? im baffled.

thanks

View Replies !
Insert Trigger
Should a insert trigger fire my update trigger as well? it fires it automatically after the insert? Is this a bug?

View Replies !
Insert Trigger Help
Hi.

Replication is not an option for me so I am trying to creat a trigger that will basically copy any new record to another database. I am using an on insert trigger and I get all records from the table inserted to the new db not just the new record.

Any ideas?

Thanks.

Bill

View Replies !
Insert Trigger (Help)
I have to create a insert trigger that calls a stored procedure usp_a
I need to pass two parameters to this stored procedure, value coming from the row inserted...
What is the syntax? Any help will be appreciated?

View Replies !
Trigger On Insert
Hi,

I have SSIS package that takes in data from an excel file and transfers it to a sql 2005 table.

I have a trigger set on the table in the sql 2005 db. However the trigger does not work when the package executes.

Am I missing something ?

 

View Replies !
Before Insert Trigger
Hi,

I've a SMS gateway that inserts SMS message into a varchar column. However, when it receives a SMS with single quote, it fails to insert into the varchar column. E.g., It's a...How's life ?....

I need help to find a workaround. Is there a equivalent of Before Insert trigger ? Also realised that the locgical 'inserted' table cannot be updated.

Advice pls.

View Replies !
Insert Trigger
I have a table that has a unique ID field.  When a new record is
inserted into the table I would like to insert the ID into 3 other
tables.  I am new to triggers and am not sure how to handle
this.  Any idea how the trigger would be written?

View Replies !
Help With Before Insert Trigger
Hi there
 
Hoping someone could steer me in the right direction with a trigger I need to create on the database, I've not done one before.  Despite reading a lot on the topic, I can't seem to get the syntax right.
 
I have a table called 'SLOC'.  This table has a field called 'Lines_In_New'.
The data to be inserted into 'SLOC' may or may not have a value for the 'Lines_In_New' field. 
I only wish to insert the rows that contain a value in this field.  So I figured a trigger before insert would do the job.
 
Something like:
 
CREATE TRIGGER sloc_trigger
    BEFORE INSERT ON SLOC
    FOR EACH ROW
    IF Lines_In_New is NOT NULL THEN
       insert the row
    END IF;

I probably have this completely wrong, but its the bit inbetween the IF statement that I'm struggling with.
 
Could anyone help me please, I'd be grateful.  Thanks.
 
 

View Replies !
Instead Of INSERT Trigger!!
Hi,

I am almost going crazy with this. I have a table that I bulk insert into from another database using VS2005.

I need to change the data in the records before committing the values in the fields. To do that I created an (Instead of Insert) trigger.

The trigger basically check conditions using IF statements and accordingly does the appropriate action, which is simply switching values between two fields (swapping).

My problem is that when the trigger fires, the logic within the if statements seem to overlap or something. The whole table fields are swapped rather than only the targeted ones.

Please tell me what is the proper syntax for having multiple (IF THEN ELSE) statements within a trigger.

Here is the code to be more specific:



Code Snippet
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[dbo_fwdcalls]
ON [dbo].[calls]

INSTEAD OF INSERT

AS

BEGIN
SET NOCOUNT ON;
IF EXISTS (SELECT joinonbehalfof FROM INSERTED
WHERE
((joinonbehalfof='10')
AND (duration > 0)
AND(LEFT(callingpartynumber,1)='8' OR LEFT(callingpartynumber,1)='9' )
AND (lastredirectdn BETWEEN '4020' AND '4024' OR lastredirectdn BETWEEN '5020' AND '5024')
))



INSERT INTO calls
SELECT [dateTimeOrigination]
,[origNodeId]
,[origSpan]
,[origIpAddr]
,[finalCalledPartyNumber]--Mark
,[origCause_location]
,[origCause_value]
,[origMediaTransportAddress_IP]
,[origMediaTransportAddress_Port]
,[destLegIdentifier]
,[destNodeId]
,[destSpan]
,[destIpAddr]
,[originalCalledPartyNumber]
,[callingPartyNumber]--Mark
,[destCause_location]
,[destCause_value]
,[destMediaTransportAddress_IP]
,[destMediaTransportAddress_Port]
,[dateTimeConnect]
,[dateTimeDisconnect]
,[lastRedirectDn]
,newid() as Pkid
,[originalCalledPartyNumberPartition]
,[finalCalledPartyNumberPartition]--Mark
,[callingPartyNumberPartition]--Mark
,[lastRedirectDnPartition]
,[duration]
,[origDeviceName]
,[destDeviceName]
,[origCalledPartyRedirectReason]
,[lastRedirectRedirectReason]
,[destConversationId]
,[origCallTerminationOnBehalfOf]
,[destCallTerminationOnBehalfOf]
,[lastRedirectRedirectOnBehalfOf]
,[joinOnBehalfOf]
FROM INSERTED


ELSE


IF EXISTS
(SELECT joinonbehalfof FROM INSERTED
WHERE
(joinonbehalfof='4')
AND (duration > 0)
AND(LEFT(callingpartynumber,1)='8' OR LEFT(callingpartynumber,1)='9' )
AND NOT (lastRedirectDn BETWEEN '4020' AND '4024' OR lastRedirectDn BETWEEN '5020' AND '5024')
AND (LEFT(lastRedirectDn,1) <> 'b')
)


INSERT INTO calls
SELECT [dateTimeOrigination]
,[origNodeId]
,[origSpan]
,[origIpAddr]
,[lastRedirectDn]--Mark
,[origCause_location]
,[origCause_value]
,[origMediaTransportAddress_IP]
,[origMediaTransportAddress_Port]
,[destLegIdentifier]
,[destNodeId]
,[destSpan]
,[destIpAddr]
,[originalCalledPartyNumber]
,[callingPartyNumber]--Mark
,[destCause_location]
,[destCause_value]
,[destMediaTransportAddress_IP]
,[destMediaTransportAddress_Port]
,[dateTimeConnect]
,[dateTimeDisconnect]
,[finalCalledPartyNumber]--Mark
,newid() as Pkid
,[originalCalledPartyNumberPartition]
,[callingPartyNumberPartition]
,[finalCalledPartyNumberPartition]
,[lastRedirectDnPartition]
,[duration]
,[origDeviceName]
,[destDeviceName]
,[origCalledPartyRedirectReason]
,[lastRedirectRedirectReason]
,[destConversationId]
,[origCallTerminationOnBehalfOf]
,[destCallTerminationOnBehalfOf]
,[lastRedirectRedirectOnBehalfOf]
,[joinOnBehalfOf]
FROM INSERTED

ELSE

IF EXISTS
(SELECT joinonbehalfof FROM INSERTED
WHERE
((joinonbehalfof='10')
AND (duration > 0)
AND(LEFT(callingpartynumber,1)='8' OR LEFT(callingpartynumber,1)='9' )
AND NOT (lastRedirectDn BETWEEN '4020' AND '4024' OR lastRedirectDn BETWEEN '5020' AND '5024')
AND (LEFT(lastRedirectDn,1) <> 'b'))
)

INSERT INTO calls
SELECT [dateTimeOrigination]
,[origNodeId]
,[origSpan]
,[origIpAddr]
,[lastRedirectDn]--Mark
,[origCause_location]
,[origCause_value]
,[origMediaTransportAddress_IP]
,[origMediaTransportAddress_Port]
,[destLegIdentifier]
,[destNodeId]
,[destSpan]
,[destIpAddr]
,[originalCalledPartyNumber]
,[callingPartyNumber]--Mark
,[destCause_location]
,[destCause_value]
,[destMediaTransportAddress_IP]
,[destMediaTransportAddress_Port]
,[dateTimeConnect]
,[dateTimeDisconnect]
,[finalCalledPartyNumber]--Mark
,NEWID() AS Pkid
,[originalCalledPartyNumberPartition]
,[callingPartyNumberPartition]
,[finalCalledPartyNumberPartition]
,[lastRedirectDnPartition]
,[duration]
,[origDeviceName]
,[destDeviceName]
,[origCalledPartyRedirectReason]
,[lastRedirectRedirectReason]
,[destConversationId]
,[origCallTerminationOnBehalfOf]
,[destCallTerminationOnBehalfOf]
,[lastRedirectRedirectOnBehalfOf]
,[joinOnBehalfOf]
FROM INSERTED



ELSE


INSERT INTO calls SELECT * From Inserted



END

View Replies !
Insert Trigger
I'm having table as below,
StudentEnroll_Thismonth
TransID(AutoNumber) | StudentID | Subject | TransDate
------------------------------------------------
1 | 0021 | A890 | 4/1/2008
2 | 0021 | A830 | 4/1/2008
3 | 0025 | A890 | 4/1/2008
4 | 0025 | A112 | 4/1/2008
5 | 0026 | A545 | 4/1/2008
.............
.............
99 | 0021 | A900 | 4/30/2008
100 | 0021 | A902 | 4/30/2008
101 | 0025 | A900 | 4/30/2008
*The table above contains what subject taken by student

Let's say, GETDATE()=5/1/2008
If execute Trans-SQL below,
INSERT INTO StudentEnroll_ThisMonth(StudentID,Subject,TransDate) values(0023,'B328',GETDATE())

How the trigger looks like to make sure the data in table shown as follow,
StudentEnroll_Thismonth
TransID(AutoNumber) | StudentID | Subject | TransDate
-----------------------------------------------------------
120 | 0023 | B328 | 5/1/2008
*All the previous month record move to StudentEnroll_PreviousMonth automatically

StudentEnroll_PreviousMonth
TransID(AutoNumber) | StudentID | Subject | TransDate
------------------------------------------------
..................
..................
..................
200 | 0021 | A890 | 4/1/2008
201 | 0021 | A830 | 4/1/2008
203 | 0025 | A890 | 4/1/2008
204 | 0025 | A112 | 4/1/2008
205 | 0026 | A545 | 4/1/2008
.................
.................
301 | 0021 | A900 | 4/30/2008
302 | 0021 | A902 | 4/30/2008
303 | 0025 | A900 | 4/30/2008

Anyone can help me to show the trigger?

View Replies !
Insert Trigger
Dear all,

I have a table named Messages with fields
Id numeric
SmsBody varchar(4000)
mobilenumber varchar(15)
Status char(1).
and also there is another table named MsgHistory with fields
Id numeric
MsgId numeric -- (will be the Id from table Messages)
SmsBody varchar(4000)
Status char(1).

I need to work a trigger if any new message (record) is inserted into table Messages, at the same time the trigger should execute to insert MsgId and SmsBody to table MsgHistory from table Messages.

How I can write trigger for this?

with regards
Shaji

View Replies !
Insert Trigger
I have an Insert Trigger on the table
I would like to know what would happen when record gets inserted from GUI(using stored procedure).

1. Record gets inserted into table , then trigger fires and stored procedure sends output to GUI.
2. Record gets inserted stored procedure sends output and then trigger fires.

Thanks

View Replies !
Help On Insert Trigger
Hi,
I need to update a createdDt field,
with currentdate only when there is a insert in the table.

Please help me with how to do this.


Thanks

View Replies !
Trigger For Insert
I have an EMPLOYEE table and DEPARTMENT table, i have to create one to many relationship where one employee can be in many departments, please guide me

create table employee (e_id INTEGER, e_fname varchar(30), e_lname varchar(30), d_id INTEGER references department(d_id))

create table department (d_id INTEGER, d_name varchar(30))

but here the problem would be while inserting into employee table since i have no primary key... do i need to use trigger to insert the right values.

View Replies !
Insert Trigger
Hi there,

After some head scratching and much research and trying I am unable to figure out how to do the following Insert Trigger. Maybe it shows a flaw in my database design?

I have a user front end where a user can assign a certain job to be done and assign it to one and only one shift and one or more equipments to do this job on.
When user clicks on Assign button it will insert rows into Jobs table via an insert stored procedure. Jobs table has following fields : ShiftID, and a JobEquipmentID since Job can be done on one or more equipment. This field, JobEquipmentID, will refer to a child table JobEquipment. What is the best approach to update this secondary table? I need to update JobEquipmentID but I do not have it until I update JobEquipment table? CRAZY!!! HELP

View Replies !
Need Help Trigger Before/After Insert
I'm new to triggers but basically what I want to do is the following, I have 2 databases name Prod and Dev In the Prod database I have a table call Sales I’m only interested in the Sale_ID field. On the Dev database I have a table call QMD and once more I’m only interested in the Sale_ID field. What I would like to do is as soon as a new record gets created in the Sales table located in the Prod database I would like to grab the Sale_ID and create a new record on the QMD table of the Dev database with the same Sale_ID, and leaving the other field blank of the newly created record.

Thank You

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved