TRIGGER a VIEW with SQL for a LINKED SERVER (ACCESS DB)

Y

youssef

Hi,
I have an ACCESS DB that I would like to import to a SQL DB.
I linked the ACCESS DB to my SQL SERVER.
For this, no problem.
After that I create a VIEW from my SQL DATABASE and I can see all RECORDS
from the ACCESS TABLE.

Now , I am looking for updating my Table from SQL DB by all new records
inserted in the ACCESS DB.

I create a TRIGGER from my VIEW. You can see below the source code :




CREATE TRIGGER TG_INSERT_LogStatus ON [dbo].[VIEW_MTX_BTS_LOG]
---------------------------------------------------------- INSERT in Log
INSTEAD OF INSERT
AS
BEGIN

My code

END
----------------------------------------------------------------------------
-----------------------------

I can execute my TRIGGER but I cannot see the new records inserted in the
ACCESS DB.

Is anyone can help me about that.
 
A

Albert D. Kallal

Does the linked table have both a primary key AND ALSO a timestamp field
exposed?

I would make sure of the above, and then delete/re-crease the link in
ms-access for the problem table. Likely when you created this table you did
not select/set a primary key.

Also, are you using a native sql project in ms-access (ADP project), or
odbc?
 
D

david epsom dot com dot au

Dunno. Will SQL Server trigger on events on foreign tables?
I don't think there is anyone here who has ever tried it.

(david)
 
Y

youssef

Hi,

I selected the primary key.

I find in a forum a solution but I don't understand how it is working.

Please find the link :

With Oracle :
http://www.experts-exchange.com/Databases/Oracle/Tools_Development/Q_20696158.html#9102669

With SQL :
http://www.experts-exchange.com/Databases/MS_Access/Q_20823443.html

Can you help me about that ?



Best Regards



david epsom dot com dot au said:
Dunno. Will SQL Server trigger on events on foreign tables?
I don't think there is anyone here who has ever tried it.

(david)

youssef said:
Hi,
I have an ACCESS DB that I would like to import to a SQL DB.
I linked the ACCESS DB to my SQL SERVER.
For this, no problem.
After that I create a VIEW from my SQL DATABASE and I can see all RECORDS
from the ACCESS TABLE.

Now , I am looking for updating my Table from SQL DB by all new records
inserted in the ACCESS DB.

I create a TRIGGER from my VIEW. You can see below the source code :




CREATE TRIGGER TG_INSERT_LogStatus ON [dbo].[VIEW_MTX_BTS_LOG]
---------------------------------------------------------- INSERT in Log
INSTEAD OF INSERT
AS
BEGIN

My code

END
--------------------------------------------------------------------------
--
-----------------------------

I can execute my TRIGGER but I cannot see the new records inserted in the
ACCESS DB.

Is anyone can help me about that.
 
D

david epsom dot com dot au

With Oracle:
He has an Oracle table.

With SQL:
He has an SQL Server table.

Do you have a SQL Server table? What is the table name? What is the name
of the database?

Does the trigger fire when you do an insert? Does it insert a new record in
the second table? Where is the second table? What is the table name? What is
the name of the database?

(david)


youssef said:
Hi,

I selected the primary key.

I find in a forum a solution but I don't understand how it is working.

Please find the link :

With Oracle :
http://www.experts-exchange.com/Databases/Oracle/Tools_Development/Q_20696158.html#9102669

With SQL :
http://www.experts-exchange.com/Databases/MS_Access/Q_20823443.html

Can you help me about that ?



Best Regards



david epsom dot com dot au said:
Dunno. Will SQL Server trigger on events on foreign tables?
I don't think there is anyone here who has ever tried it.

(david)

youssef said:
Hi,
I have an ACCESS DB that I would like to import to a SQL DB.
I linked the ACCESS DB to my SQL SERVER.
For this, no problem.
After that I create a VIEW from my SQL DATABASE and I can see all RECORDS
from the ACCESS TABLE.

Now , I am looking for updating my Table from SQL DB by all new records
inserted in the ACCESS DB.

I create a TRIGGER from my VIEW. You can see below the source code :




CREATE TRIGGER TG_INSERT_LogStatus ON [dbo].[VIEW_MTX_BTS_LOG]
---------------------------------------------------------- INSERT in Log
INSTEAD OF INSERT
AS
BEGIN

My code

END

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

I can execute my TRIGGER but I cannot see the new records inserted in the
ACCESS DB.

Is anyone can help me about that.
 
Y

youssef

Hi,

Thank for your time.

So, I have one Table in the ACCESS DB.
This DB, I linked with SQL SERVER.
At this moment, I can connected to the ACCESS DB from my SQL SERVER (LINKED
SERVER NAME : MTX_BTS_LOG)

Now I create in my SQLSERVER a DB with the same structure TABLE than the
ACCESS DB.
the Name of the Table is : [Router Status]

In this way, I create in my SQL DB, a view (VIEW_MTX_BTS_LOG) that represent
the TABLE of the linked server( ACCESS DATABASE).
The name of the VIEW : VIEW_MTX_BTS_LOG

SELECT * FROM MTX_BTS_LOG...[Router Status]

When I exectute the VIEW, I see all records from the TABLE of my ACCESS DB.

Now, I create a TRIGGER from this VIEW with this code :


CREATE TRIGGER TG_INSERT_LogStatus ON [dbo].[VIEW_MTX_BTS_LOG]
---------------------------------------------------------- INSERT in Log
INSTEAD OF INSERT
AS
BEGIN

My code => Insert the new record in my SQL TABLE

END
--------------------------------------------------------------------------

Now, the TRIGGER is created but nothing when a new record is inserted in the
ACCESS DB.

Can you help me ?

Best Regards


david epsom dot com dot au said:
With Oracle:
He has an Oracle table.

With SQL:
He has an SQL Server table.

Do you have a SQL Server table? What is the table name? What is the name
of the database?

Does the trigger fire when you do an insert? Does it insert a new record in
the second table? Where is the second table? What is the table name? What is
the name of the database?

(david)


youssef said:
Hi,

I selected the primary key.

I find in a forum a solution but I don't understand how it is working.

Please find the link :

With Oracle :
http://www.experts-exchange.com/Databases/Oracle/Tools_Development/Q_20696158.html#9102669
With SQL :
http://www.experts-exchange.com/Databases/MS_Access/Q_20823443.html

Can you help me about that ?



Best Regards



david epsom dot com dot au said:
Dunno. Will SQL Server trigger on events on foreign tables?
I don't think there is anyone here who has ever tried it.

(david)

Hi,
I have an ACCESS DB that I would like to import to a SQL DB.
I linked the ACCESS DB to my SQL SERVER.
For this, no problem.
After that I create a VIEW from my SQL DATABASE and I can see all RECORDS
from the ACCESS TABLE.

Now , I am looking for updating my Table from SQL DB by all new records
inserted in the ACCESS DB.

I create a TRIGGER from my VIEW. You can see below the source code :




CREATE TRIGGER TG_INSERT_LogStatus ON [dbo].[VIEW_MTX_BTS_LOG]
---------------------------------------------------------- INSERT in Log
INSTEAD OF INSERT
AS
BEGIN

My code

END

-------------------------------------------------------------------------- in
the
ACCESS DB.

Is anyone can help me about that.
 
D

david epsom dot com dot au

OK, the examples you quoted are for
SQL Server tables
and
Oracle tables

You have an
ACCESS DB Table

I'm sorry, but I don't think you can use SQL Server Triggers
for an ACCESS DB Table.

However, if I am wrong, if you can use a SQL Server Trigger,
then you should try to use an
UPDATE TRIGGER
instead of INSERT TRIGGER.

It is normal to see external database inserts done as a blank insert, with a
real update.

(david)



youssef said:
Hi,

Thank for your time.

So, I have one Table in the ACCESS DB.
This DB, I linked with SQL SERVER.
At this moment, I can connected to the ACCESS DB from my SQL SERVER (LINKED
SERVER NAME : MTX_BTS_LOG)

Now I create in my SQLSERVER a DB with the same structure TABLE than the
ACCESS DB.
the Name of the Table is : [Router Status]

In this way, I create in my SQL DB, a view (VIEW_MTX_BTS_LOG) that represent
the TABLE of the linked server( ACCESS DATABASE).
The name of the VIEW : VIEW_MTX_BTS_LOG

SELECT * FROM MTX_BTS_LOG...[Router Status]

When I exectute the VIEW, I see all records from the TABLE of my ACCESS DB.

Now, I create a TRIGGER from this VIEW with this code :


CREATE TRIGGER TG_INSERT_LogStatus ON [dbo].[VIEW_MTX_BTS_LOG]
---------------------------------------------------------- INSERT in Log
INSTEAD OF INSERT
AS
BEGIN

My code => Insert the new record in my SQL TABLE

END
--------------------------------------------------------------------------

Now, the TRIGGER is created but nothing when a new record is inserted in the
ACCESS DB.

Can you help me ?

Best Regards


david epsom dot com dot au said:
With Oracle:
He has an Oracle table.

With SQL:
He has an SQL Server table.

Do you have a SQL Server table? What is the table name? What is the name
of the database?

Does the trigger fire when you do an insert? Does it insert a new
record
in
the second table? Where is the second table? What is the table name?
What
is
the name of the database?

(david)
http://www.experts-exchange.com/Databases/Oracle/Tools_Development/Q_20696158.html#9102669
With SQL :
http://www.experts-exchange.com/Databases/MS_Access/Q_20823443.html

Can you help me about that ?



Best Regards



Dunno. Will SQL Server trigger on events on foreign tables?
I don't think there is anyone here who has ever tried it.

(david)

Hi,
I have an ACCESS DB that I would like to import to a SQL DB.
I linked the ACCESS DB to my SQL SERVER.
For this, no problem.
After that I create a VIEW from my SQL DATABASE and I can see all
RECORDS
from the ACCESS TABLE.

Now , I am looking for updating my Table from SQL DB by all new records
inserted in the ACCESS DB.

I create a TRIGGER from my VIEW. You can see below the source code :




CREATE TRIGGER TG_INSERT_LogStatus ON [dbo].[VIEW_MTX_BTS_LOG]
---------------------------------------------------------- INSERT
in
Log
INSTEAD OF INSERT
AS
BEGIN

My code

END

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

I can execute my TRIGGER but I cannot see the new records inserted in
the
ACCESS DB.

Is anyone can help me about that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SQL View Help 2
upsize to sql server 6
Help with SQL view 4
Advice - SQL DB 12
linked table from ACCESS 3
Access 2007 and connecting to SQL server 2008 6
how to link to sql server db 1
access db to mysql db table? 6

Top