• tstagliano (7/8/2013)


    One last piece of advice i need. i am able to run this for the first time, but i need to delete the dbo.tblPlexActualPrice table everytime the SPROC runs so i can be re-created. I tried to add a DELETE FROM and INSERT INTO statement but it error out on the syntax where is creates the table.

    Now you are confusing me; if the table gets data inserted into it, and then you want to destroy the table, what is the procedure supposed to actually do then?

    if it creates and destroys the data, it's really doing nothing; maybe you left out some other code? chances are the table needs to exist BEFORE the procedure runs, and so the procedure should not be creating anything...just inserting into your table; i think you might just have vestiges of a copy/paste from my first examples?

    if you really need to destroy the table, use a temp table instead.

    Create and insert into #tblPlexActualPrice in this case;

    the usage of a temp table, instead of a permanent table, allows for full concurrency, meaning two or hundreds of people can call the same procedure at the same time, without one of them pausing or crashing.

    a temp table, created in a procedure, is automatically destroyed when it goes out of scope(the procedure ends). a temp table with that name is unique to the session, so 100 people can create their own version of that table, with the same name, even with different schemas and data, than any of the other sessions.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!