HighTechTalks DotNet Forums  

DataBase Refresh

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss DataBase Refresh in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
stix
 
Posts: n/a

Default DataBase Refresh - 09-01-2006 , 01:04 AM






I have a stored procedure in which I basically copy the schema from one
table into a temporary table.
Select * into dbo.myNewTable from dbo.myoldtable where 1 = 0

The problem is that when I goto alter that table to add the Primary key to
it (as that part of the schema did not copy)
I get an Invalid Object Error dbo.myNewTable does not exist...
BUT IT DOES EXIST!!!

Any one have any ideas as to what I am doing wrong

I open the conection
execute the stored procedure to create the table
I close the connection

I open the connection again
Alter the Table to set a primary key and it errors
Does any one know why ? - I put wait in the procedure
and that does not work.



Reply With Quote
  #2  
Old   
Mary Chipman [MSFT]
 
Posts: n/a

Default Re: DataBase Refresh - 09-04-2006 , 01:59 PM






The problem you are having is related to the scope of temp tables in
SQL Server. A temp table exists for the duration of a connection
UNLESS it is created inside of a stored procedure, in which case it
lives only for the duration of the stored procedure. It does not
persist between calls or between connections. You need to perform all
operations on the temp table inside of the stored procedure, not in
separate calls.

--Mary

On Fri, 1 Sep 2006 01:04:50 -0400, "stix" <stixoffire (AT) hotmail (DOT) com>
wrote:

Quote:
I have a stored procedure in which I basically copy the schema from one
table into a temporary table.
Select * into dbo.myNewTable from dbo.myoldtable where 1 = 0

The problem is that when I goto alter that table to add the Primary key to
it (as that part of the schema did not copy)
I get an Invalid Object Error dbo.myNewTable does not exist...
BUT IT DOES EXIST!!!

Any one have any ideas as to what I am doing wrong

I open the conection
execute the stored procedure to create the table
I close the connection

I open the connection again
Alter the Table to set a primary key and it errors
Does any one know why ? - I put wait in the procedure
and that does not work.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.