SQLServer #TEMP table for individual users linked to Access 2010

Posted on 2011-10-26
Last Modified: 2013-11-27

I have an Access 2010 routine that :
- copies from one of my main SQLServer tables all records to a 'local user' MDB (on the local users's C drive) all the records, is a temp MDB. It copies about 800 records , the table has about 20 columns, so is relatively fast copy procedure

- with that local temp MDBs table linked to the front end a user chooses, via an Access form, some or all of those records in that linked temp  table, i.e. one of the fields is a YesNo field.
- from there I use some VBA and read that list of records that linked temp  table and if a record is marked Yes I do something with that record

But I am wondering instead of using a temp MDB on the users C drive, can I somehow use a SQL Server #TEMP table and link that to the Access Front End (table ? view? USP ? ) and if so is that linked #TEMP table unique to an individual user/logon ? i.e. someone's list of YesNo records in 'their' #TEMP is not going to be overridden with someone elses list in 'their' #TEMP ? The #TEMP SQLServer table would be linked to Access 2010 and used and viewed in a form and used as  a recordset (list) in a VBA procedure

the FrontEnd interface is on a terminal server and all users log on to that and fire up the interface and use it on the TS.

thanks, a bit vague but not quite sure how to ask the quesiton on SQL #temp table, unsure of their uniqueness and duration and link-ability to Acc2010.

I have SQLServer v2008, DevEdition
Question by:LukeB
    LVL 84

    Accepted Solution

    SQL Server Temporary tables are unique to each user/connection. From here: (Temporary Tables section, about midway through the article):

    "If a local temporary table is created in a stored procedure or application that can be executed at the same time by several users, SQL Server has to be able to distinguish the tables created by the different users. SQL Server does this by internally appending a numeric suffix to each local temporary table name"

    Temp tables are available throughout a single "session", which would generally be the length of your connection to the db. If you build a global connection to the server when your app starts and "kill" that connection when it ends, I would think that your temp table would be available throughout that connection session.

    However, I don't think you could link a Temp table to your Access FE. I found a few forum posts that seem to support this, but the comments were somewhat vague. I've never tried to do anything like this, so don't know if you could, but it would seem to make sense that you could not link. In your case, unless you want to build an interface that works with unbound data, and use your temp table to fill local recordsets, etc you might be better off staying with your current setup.

    LVL 56

    Expert Comment

    by:Jim Dettman (Microsoft MVP/ EE MVE)

      From what I'm aware, temp tables are only available within SQL itself.  I don't know of any way to link to one from Access itself.

     No points here please.

    LVL 1

    Author Comment

    thanks guys, if ok by you I leave this posted this week, maybe the folk over in SQL side of EE have an idea ?
    LVL 1

    Author Comment

    PS: one thing I am thinking about is to have SQL 'temp' table but not a true #temp one. The table still gets filled with the same data but I add another filed with the users SQL logon id (it is a Windows logon security ). Then on the Access side in the view I just show that user their records in that temp table, and they use those. The records will get dropped and added for that user, other user record are kept.

    i will let you know how that goes later in week
    LVL 84
    You could do that as well - whatever works best for your situation. SQL Temp tables are useful if the fulfill your needs, of course. In later versions there are also @table variables, which often serve the same purpose. However, those are very tightly scoped, so be sure to consider this if you look into @table variables.
    LVL 1

    Author Closing Comment

    thanks guys, that saved me a bit of looking. Marked as 'partial complete solution' as I will have to find a workaround.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now