﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Strategies  / Run stored procedure when temp table is created/dropped / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 03:04:59 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>Hi,It seams to be not that easy/possible to catch this at server-side.I'm going to dig into the code and seach for those temp tables (and centralize it :-)).Thanks for the help on this topic.grtzJo</description><pubDate>Mon, 28 Jan 2013 08:44:44 GMT</pubDate><dc:creator>jo.wouters</dc:creator></item><item><title>RE: Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>Hm.  Maybe using SQL Profiler?  Trap all "CREATE TABLE #" commands?  ...just a thought...</description><pubDate>Wed, 23 Jan 2013 08:55:31 GMT</pubDate><dc:creator>Your Name Here</dc:creator></item><item><title>RE: Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>[quote][b]Lowell (1/22/2013)[/b][hr]i am wondering if you could put an extended event for CREATE_TABLE on the tempdb?[/quote]I thought of that too, but it's SQL 2005.</description><pubDate>Tue, 22 Jan 2013 13:56:00 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>i am wondering if you could put an extended event for CREATE_TABLE on the tempdb?I'll grab one of my sample extended events and try it, but it's just an idea for now; i'd think that the extended event would be destroyed on start/stop of the server, so you'd need something that keeps adding it back, if an extended event is even allowed.</description><pubDate>Tue, 22 Jan 2013 12:38:30 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>I did explore this further yesterday and wondered about your apps architecture. You could create these global temp files (##ABC) and look through the tempdb.sys.tables table to locate them, but they will only exist for as long as there exists a connection that references them. So, if your VB app creates them, writes to them and then disappears (dropping the connection), the file(s) will be dropped also. But, if the VB app is continously running and keeping the SQL connection open, you could create a 'polling' job that would execute every N minutes/seconds that would query tempdb.sys.tables for entries for temp file names that match your pattern. So, your update process wouldn't be 'triggered' by an event, but would be 'discovered' by a process that goes out and checks (polls) for data.Then you'd probably have to use some dynamic SQL to actually query those temp tables to get the data out of them for your update process.Not sure I'd agree that this is the most robust architecture, but I suppose it depends on your system and your situation.</description><pubDate>Tue, 22 Jan 2013 11:27:17 GMT</pubDate><dc:creator>Rob Schripsema</dc:creator></item><item><title>RE: Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>Thanks for the replies.Does any one else have an idea how to solve this?grtzJo</description><pubDate>Tue, 22 Jan 2013 01:43:57 GMT</pubDate><dc:creator>jo.wouters</dc:creator></item><item><title>RE: Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>You could do this with SQL Server Integration Services (SSIS) running on a tight schedule (every few minutes?) or with SSIS and the FileWatcher task (available from www.sqlis.com), which will detect changes to folders on the server.Edit: Sorry, I may have mis-read your post. You're looking at temp tables, not files dropped to a folder. My solution probably won't solve your problem then.</description><pubDate>Mon, 21 Jan 2013 12:20:57 GMT</pubDate><dc:creator>Rob Schripsema</dc:creator></item><item><title>RE: Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>I checked to be sure and DDL triggers FOR CREATE_TABLE do not fire when a global temp table is created. I do not know of way to accomplish what you're after.</description><pubDate>Mon, 21 Jan 2013 10:26:58 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>Run stored procedure when temp table is created/dropped</title><link>http://www.sqlservercentral.com/Forums/Topic1409477-361-1.aspx</link><description>Hi guys and girls,I need to update 1 or 2 records in my database each time a temp table with the name like '##ABC_%' is created/dropped.(Note: Temp tables are created from my application.)I can do this in my application (VB.NET), but I didn't wrote it and the guy before me didn't understand multi-tier/OO.So I want to move the update part to the SQL Server (if possible).Is there a way in SQL2005 to detect the creation/deleting of a temp table and then run a SP?All ideas/thoughts are welcome.GrtzJo</description><pubDate>Mon, 21 Jan 2013 04:33:46 GMT</pubDate><dc:creator>jo.wouters</dc:creator></item></channel></rss>