Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
Trigger will not export to Excel Spreadsheet
Trigger will not export to Excel Spreadsheet
Rate Topic
Display Mode
Topic Options
Author
Message
rclarkson
rclarkson
Posted Tuesday, January 08, 2008 8:43 AM
Forum Newbie
Group: General Forum Members
Last Login: Thursday, January 10, 2008 4:09 AM
Points: 2,
Visits: 6
Hiya all, this is my first post here. I hope you can help me.
I have a trigger attached to a table that will export data to an Excel spreadsheet when a record is inserted to that table. When I insert the record, I get the following error:
The current transaction could not be exported to the remote provider. It has been rolled back.
The script I am using is below:
Insert into OpenDataSource
(
'Microsoft.Jet.OLEDB.4.0', 'Data Source=C:\ITTeam\Excel\Book1.xls;Extended Properties=Excel 8.0'
)
...[Sheet1$]
SELECT * FROM CUSTOMERS
I think the script is OK because it works when:
1. I execute the script from a SqlClient.SqlCommand object within a VB .Net application
2. If I place the script in a stored procedure and execute it from a VB .Net application.
Thanks in anticipation
Rob
Post #440096
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Tuesday, January 08, 2008 9:07 AM
SSC-Dedicated
Group: Administrators
Last Login: Today @ 5:09 AM
Points: 31,526,
Visits: 13,864
First, triggers are inside the transaction and putting something that needs external resources (send mail, openrowsource, etc.) is a bad idea. You are asking for lots of issues.
Insert the row into a table and then periodically, even every minute, run an export with SSIS to throw this into your spreadsheet.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #440113
David.Poole
David.Poole
Posted Tuesday, January 08, 2008 12:47 PM
SSCrazy
Group: General Forum Members
Last Login: Today @ 7:28 AM
Points: 2,766,
Visits: 1,441
I would create a table that holds a flag.
Have your trigger set the flag
Set up a schedule job that runs every minute or so with a task that says
IF EXISTS(SELECT 1 FROM dbo.FlagTable WHERE Flag=1)
BEGIN
UPDATE dbo.FlagTable SET Flag=1
exec your query
END
The alternative is to have the trigger start your job but you need to put the check in place to detect if your job is running already. There is a system management view for this but its name escapes me.
LinkedIn Profile
Post #440248
Jeff Moden
Jeff Moden
Posted Tuesday, January 08, 2008 6:45 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 7:18 AM
Points: 33,112,
Visits: 27,038
Exporting to spreadsheet is "Death by SQL"... if someone opens it, BOOM! Process in SQL is dead... period.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #440373
Sergiy
Sergiy
Posted Tuesday, January 08, 2008 7:41 PM
SSCarpal Tunnel
Group: General Forum Members
Last Login: Today @ 8:01 AM
Points: 4,557,
Visits: 8,237
In MS Excel go to Data -> Import External Data -> New Database Query.
Follow instructions in the wizard to create a query to your database.
Post #440389
rclarkson
rclarkson
Posted Wednesday, January 09, 2008 7:39 AM
Forum Newbie
Group: General Forum Members
Last Login: Thursday, January 10, 2008 4:09 AM
Points: 2,
Visits: 6
Hiya folks, thanks for your responses. So... does anybody know why the error
The current transaction could not be exported to the remote provider. It has been rolled back.
is occurring and how we can fix it? That would be a problem solved.
Thanks
Rob
Post #440658
Loner
Loner
Posted Wednesday, January 09, 2008 8:24 AM
SSCrazy
Group: General Forum Members
Last Login: Yesterday @ 2:26 PM
Points: 2,740,
Visits: 2,941
As Steve said before,
DO NOT USE TRIGGER
!!!!!
Post #440702
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.