Concurrency With #Temp Tables in Sprocs

  • Afternoon All

    I have a quick question.

    I'm am in the process of re-writing some sprocs and rather than use udf's or table variable I am using #temp tables.

    In essence they follow a similar format

    CREATE PROCEDURE A

    AS

    BEGIN

    IF OBJECT_ID('tempdb..#TEMP') IS NOT NULL

    DROP TABLE #TEMP

    CREATE TABLE #Temp

    (A INT)

    INSERT INTO #Temp

    < Do some bits >

    DROP TABLE #Temp

    END

    My question is could the temp table cause any concurrency issues either from the other sprocs creating a temp table or another user calling the sproc at the same time?

    I'm thinking not but I want to make sure :ermm:

    Thanks

    Andy

    ==========================================================================================================================
    A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe

  • You shouldn't have concurrency problems with #Temp tables as they're exclussive by session.

    http://msdn.microsoft.com/en-us/library/ms177399%28v=sql.105%29.aspx

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply