Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 change database inside the SP Transaction

Author  Topic 

rubs_65
Posting Yak Master

144 Posts

Posted - 2004-11-03 : 14:13:36
Hi,

We have a table having columns
Old_schema - storing the table structure before the modification New schema - storing the table structure after the modification Change - alter statement

Now I have a bcp file of a table with the old schema that I need to put back to table with new schema (current) so plan is to run the sql statement stored in old schema column , bcp in, apply all the alter changes, put data in new table. Since old and new schema table names are same we are thinking of creating old schema table in tempdb and later drop it. Since this all will be done in SP, How can we change the database inside the SP so that the old schema table script will go to the tempdb. One way is to search for table name and append with tempdb..table_name but I am checking if there is any other way to alter the database inside the schema so that I can avoid this search/replace pattern inside the SP. We can't put # so this is not an option.

Thanks
--Harvinder

Kristen
Test

22859 Posts

Posted - 2004-11-03 : 14:46:06
Can you make a VIEW with the Old Schema column names which actually references the New Schema?

Kriten
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-11-03 : 15:20:17
You can access tables in other databases from inside the proc,
just use 3 part naming

select ... from dbname.owner.table

Also you can have 2 tables with same name but different owners in same db
old.mytable
dbo.mytable


rockmoose
Go to Top of Page
   

- Advertisement -